Note that there are some explanatory texts on larger screens.

plurals
  1. POSelectedRowStyle Not Changing BgColor of Cells With Defined CSS Style
    text
    copied!<p>I've got GridView with selection enabled. Some columns in GridView have CssClass set, setting their background color. Also, there is SelectedRowStyle defined in GridView.</p> <p>Problem is, after row is selected, it's background color is changed as defined in SelectedRowStyle, except columns with own CssClass set. Their background color remains unchanged, and I would like all columns in selected row to have same color (defined in SelectedRowStyle).</p> <p>I'm using VS2008 and .NET Framework 3.5.</p> <p>GridView:</p> <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" OnRowDataBound="GridView1_RowDataBound" AllowPaging="True" PageSize="50" CssClass="gv" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanged="GridView1_PageIndexChanged" DataKeyNames="Name" RowStyle-Wrap="False"&gt; &lt;RowStyle Font-Names="Calibri" Font-Size="Small" BackColor="White" ForeColor="#333333" /&gt; &lt;SelectedRowStyle BackColor="#336699" Font-Bold="True" ForeColor="White" /&gt; &lt;Columns&gt; &lt;asp:BoundField DataField="Name" HeaderText="Name" SortExpression="Name" /&gt; &lt;asp:BoundField DataField="Model" HeaderText="Model" SortExpression="Model" /&gt; &lt;asp:BoundField DataField="Qty" HeaderText="Qty" SortExpression="Qty" /&gt; &lt;asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" /&gt; &lt;asp:BoundField DataField="Level" HeaderText="Level" SortExpression="Level" ItemStyle-CssClass="bglightred" /&gt; &lt;asp:BoundField DataField="Log" HeaderText="Log" SortExpression="Log" ItemStyle-CssClass="bglightred" /&gt; &lt;/Columns&gt; </code></pre> <p></p> <p>CSS:</p> <pre><code> .gv td.bglightred { background-color: #FF8080; } .gv tr:hover td { background-color: #CCCCCC;cursor: default; } </code></pre> <p>Code:</p> <pre><code> protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(GridView1, "Select$" + e.Row.RowIndex.ToString())); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload