I have check boxes in the gridview for each row. When i checked a particular row's checkbox the enrire row should be selected. It is working but when i checked another checkbox, the previous checked row is not selecting. Only current row is selected. I need to select all the rows which i have checked.
I tried in this way,
private void GridView_MouseUp(object sender, MouseEventArgs e)
{
for
(int i = 0; i < GridView.Rows.Count; i++)
{
if (GridView.Rows[i].Cells["chk"].Selected == true) //CellElement.RowInfo.IsSelected)
{
//GridView.Rows[i].Cells["chk"].RowInfo.IsSelected = true;
GridView.Rows[i].Cells["chk"].CellElement.RowElement.IsSelected = true;
}
else //if (Convert.ToBoolean(GridView.Rows[i].Cells["chk"].RowInfo.IsSelected))
{
//GridView.Rows[i].Cells["chk"].RowInfo.IsSelected = false;
GridView.Rows[i].Cells[
"chk"].CellElement.RowElement.IsSelected = false;
}
}
i tried with mousedown and mouse click also. It is not working.
note: The checkbox column is added to grid programatically.