My problem is that I can properly handle my listbox
where I'm doing a "range of values" in my system.
I need it not to let codebehind add a value that is contained in the range of values .. Ex: 0-10 was added, now I can not let it add 9-20 because 9 is contained in the 0-10 range. .
How can I proceed? The system images and their lines of code are attached.
protectedvoidbtnAdicionarGastos_Click(objectsender,EventArgse){if(Tratar.Int(txtGastosDe.Value)<=Tratar.Int(txtGastosAte.Value)){stringgasto=txtGastosDe.Value+" - " + txtGastosAte.Value;
if (!string.IsNullOrEmpty(gasto))
{
DataTable dt = new DataTable("dxlstGastos");
if (lstGastos.Visible == false)
{
lstGastos.Visible = true;
btnRemoverGastos.Visible = true;
}
if (!string.IsNullOrEmpty(txtGastosDe.Value) && !string.IsNullOrEmpty(txtGastosAte.Value))
{
if (!lstGastos.Items.Contains(lstGastos.Items.FindByText(gasto)))
{
dt.Columns.Add("GASTOS");
foreach (ListItem item in lstGastos.Items)
{
DataRow dr;
dr = dt.NewRow();
dr["GASTOS"] = item.Value;
dt.Rows.Add(dr);
}
DataRow row = dt.NewRow();
row.BeginEdit();
row["GASTOS"] = gasto;
row.EndEdit();
dt.Rows.InsertAt(row, 0);
dt.AcceptChanges();
lstGastos.DataSource = dt;
lstGastos.DataTextField = "GASTOS";
lstGastos.DataBind();
}
}
}
else
{
Alerta("Não insira valores em branco.");
}
}
else
{
Alerta("Por favor, insira valores finais maiores que os iniciais.");
}
}