我有一个数据网格,它在行中有一个复选框。单击复选框时,我想更改行的背景颜色。示例代码:
<asp:DataGrid ID="Grid" runat="server" DataKeyField="KeyID" CssClass="grid"
AutoGenerateColumns="False" CellPadding="10" ForeColor="#333333"
GridLines="None" OnPageIndexChanged="Grid_PageIndexChanged"
OnEditCommand="Grid_EditCommand" OnDeleteCommand="GetResult"
onitemdatabound="Grid_ItemDataBound" >
<Columns>
<HeaderTemplate>
<input id="chkAllItems" type="checkbox" onclick="javascript:HeaderClick(this);"/>
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "KeyID")%>' ID="checkBoxID" AutoPostBack="false" OnClick="chechkedChanged(this);" ></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn>
<HeaderTemplate>
<label for="male">Category</label>
</HeaderTemplate>
<ItemTemplate>
<asp:TextBox Text="" ID="Category" runat="server" AutoPostBack="false" MaxLength="10" CssClass="tb5" > </asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" HeaderText="Edit">
</asp:EditCommandColumn>
<asp:ButtonColumn CommandName="Delete" HeaderText="TDK" Text="tdk"></asp:ButtonColumn>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" Mode="NumericPages" />
<AlternatingItemStyle BackColor="#FAAC58" />
<ItemStyle BackColor="#81DAF5" ForeColor="#333333" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
</asp:DataGrid>
如何在 javascript 中更改行的背景颜色?