Im develop a shopping cart and I need to count how many times is clicked one row in a gridview to get the sum for this item.
I tried to figure out how to do, and I tried with dictionary to get the key (row) and value (count), but I dont know how to modified the value of the dictionary.
static Dictionary <int, int> list = new Dictionary <int, int>();
protected void SelectedIndexChanged (object sender, EventArgs e)
{
for(int i=0 ; i < 100 ; i++)
{
list.add(i,0);
}
foreach (var item in list)
{
if(item == gridview1.GridView1.SelectedRow.DataItemIndex)
list.key[item] = newInt;
}
}
ok. I think you need to initialize your list outside the event handler.