>string NormalRowColor = e.Row.BackColor.ToString(); > CheckBox cb = (CheckBox)e.Row.FindControl("chkReq"); > if (cb != null) > { > > if (cb.Checked) > { > e.Row.BackColor = System.Drawing.Color.LightGray; > } > > string js = "javascript:colorRow(event," + NormalRowColor + ")"; > cb.Attributes.Add("OnClick", js); > } > >>
>function colorRow(e,normalColor) >{ >// Annoying code to get the desired event handler from the browser. > if (!e) e = window.event; > var srcEl = e.target || e.srcElement; > > var curElement = srcEl; > while (curElement && !(curElement.tagName == "TR")) > { > // Keep going until we reach the parent table row > curElement = curElement.parentNode; > } > if (curElement != srcEl) > { > if (srcEl.checked) > { > // Modify your colors here for a selected object > curElement.style.foregroundColor = "White"; > curElement.style.backgroundColor = "#LightGrey"; > } > else > { > // Modify your colors for a deselected object (read: Normal) > curElement.style.foregroundColor = "Black"; > curElement.style.backgroundColor = normalColor; > } > } >} >See http://www.gridviewguy.com/ArticleDetails.aspx?articleID=172