I’m trying to count the rows in a DataList where id is 3 and put the value in a label.
for (int i = 0; i < Product.Items.Count; ++i)
{
if (table.Rows[i]["id"].ToString() == "3")
{
int x = x + 1;
lblCounter.text = x.ToString
}
}
Will not work. You have to do something like
before the loop and
inside it. Additionally, you might want to put
lblCounter.text = x.ToStringafter the loop, so as to update it just once.This makes