0
My problem is that I can treat my listbox
where I am doing a "value range" in my system.
I need it not to let codebehind add a value that is contained in the value range.. Ex: 0-10 has been added, now I can’t let it add 9-20 as 9 is contained in track 0-10..
How can I proceed? See attached images of the system and its lines of code.
protected void btnAdicionarGastos_Click(object sender, EventArgs e)
{
if (Tratar.Int(txtGastosDe.Value) <= Tratar.Int(txtGastosAte.Value))
{
string gasto = 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.");
}
}
You didn’t edit anything, you’re not even Ricardo?
– Renan Serrão Nogueira