在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
前台: 复制代码 代码如下: <asp:TemplateField HeaderText="选择"> <ItemStyle HorizontalAlign="Center"/> //居中显示 <ItemTemplate> <asp:CheckBox ID="ckbSelect" runat="server" AutoPostBack="true" oncheckedchanged="ckbSelect_CheckedChanged" /> </ItemTemplate> </asp:TemplateField> 后台: 复制代码 代码如下: /// <summary> /// checkbox选中时,改变行颜色 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void ckbSelect_CheckedChanged(object sender, EventArgs e) { for (int i = 0; i < this.gvStudent.Rows.Count; i++) { CheckBox cb = (CheckBox)this.gvStudent.Rows[i].FindControl("ckbSelect"); if (cb.Checked) { this.gvStudent.Rows[i].BackColor = System.Drawing.Color.FromName("#e2eaec"); } else { this.gvStudent.Rows[i].BackColor = System.Drawing.Color.Empty; } } } |
请发表评论