In datagrid view select cells want to highlightcolor?
While click on the cells in the datagrid view want to be change in color.and also undo the selected cells
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Joginder BangerPosted Feb 13, 2015, 1:07 PM
try this one
protected void btn_GrdClick(object sender, EventArgs e)
{
if(Session["PreviousRowIndex"] != null)
{
var previousRowIndex = (int)Session["PreviousRowIndex"];
GridViewRow PreviousRow = MyGridView.Rows[previousRowIndex];
PreviousRow.ForeColor = Color.White;
}
GridViewRow row = (GridViewRow)((Button)sender).NamingContainer;
row.ForeColor = Color.Yellow; Session["PreviousRowIndex"] = row.RowIndex;
}