I have a checkbox in a grid view.
What I want to happen is that if the checkbox is ticked it should have a red colour for the datagrid row.
If it isnt it should have a white colour
Any help rergarding this will be appreciated.
Regards.
Loading
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.
suraj ghosiPosted Apr 29, 2015, 2:02 AM
Try this
protected void mygrid_RowDataBound(Object sender, GridViewRowEventArgs e)
{
foreach(GridViewRow gvrow in myGrid.Rows)
{
CheckBox chk = (CheckBox)gvrow.FindControl("chkSelect");
if (chk.Checked)
{
grRow.BackColor = Color.Red;
}
else {
grRow.BackColor = Color.White;
}}