Hi
I have girdview with product id and price when the user select row from gridview the product id shpuld be added to listbox and when the user click on delete button the selected row in the listbox should be removed from the gridview ..
here is my code for selecting the item and adding them to the listbox
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
GridViewRow row = GridView1.SelectedRow;
string id = row.Cells[0].Text;
ListItem list = new ListItem(id);
if (ListBox1.Items.Contains(list) == false)
{
ListBox1.Items.Add(id);
}
and this is what I did so far for the delete button I'm not sure if it correct
protected void btnDeleteFromListBox_Click1(object sender, EventArgs e)
{
string choice = ListBox1.SelectedItem.Text;
GridViewRow row = GridView1.SelectedRow;
string id = row.Cells[0].Text;
foreach (GridView a in GridView1.Rows)
{
if (choice == id)
{
}
}
}
}