CheckBox的全选与不全选(刷新页面效果)
来源:互联网 发布:发布淘宝类目如何选择 编辑:程序博客网 时间:2024/05/01 19:52
aspx文件:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wangyi.aspx.cs" Inherits="_12._18zuoye.wangyi" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="sid" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" AutoPostBack="True"
oncheckedchanged="CheckBox2_CheckedChanged" />
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="sid" HeaderText="sid" InsertVisible="False"
ReadOnly="True" SortExpression="sid" />
<asp:BoundField DataField="sname" HeaderText="sname" SortExpression="sname" />
<asp:BoundField DataField="sex" HeaderText="sex" SortExpression="sex" />
<asp:BoundField DataField="age" HeaderText="age" SortExpression="age" />
</Columns>
</asp:GridView>
<br />
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:studentConnectionString %>"
DeleteCommand="DELETE FROM [student] WHERE [sid] = @sid"
InsertCommand="INSERT INTO [student] ([sname], [sex], [age]) VALUES (@sname, @sex, @age)"
SelectCommand="SELECT [sid], [sname], [sex], [age] FROM [student]"
UpdateCommand="UPDATE [student] SET [sname] = @sname, [sex] = @sex, [age] = @age WHERE [sid] = @sid">
<DeleteParameters>
<asp:Parameter Name="sid" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="sname" Type="String" />
<asp:Parameter Name="sex" Type="String" />
<asp:Parameter Name="age" Type="Byte" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="sname" Type="String" />
<asp:Parameter Name="sex" Type="String" />
<asp:Parameter Name="age" Type="Byte" />
<asp:Parameter Name="sid" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</div>
</form>
</body>
</html>
aspx.cs文件:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace _12._18zuoye
{
public partial class wangyi : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
{
CheckBox ckb = sender as CheckBox;//捉住CheckBook2
foreach (GridViewRow row in this.GridView1.Rows)
{
if (row.RowType==DataControlRowType.DataRow)
{
(row.Cells[0].FindControl("CheckBox1") as CheckBox).Checked = ckb.Checked;//把他的选择状态给那些记录中的CheckBook
}
}
}
}
}
- CheckBox的全选与不全选(刷新页面效果)
- CheckBox全选与不全选(不用刷新页面)
- checkbox的全选效果
- JS checkbox 全选与不全选
- checkbox的全选和不全选
- 实现全选和取消全选(JavaScript控制CheckBox 的全选与取消全选)
- checkbox的全选与取消全选
- 页面上的checkbox-------全选
- 全选与不全选
- 全选与不全选
- button实现一组checkbox的全选与全不选效果
- checkbox全选与取消全选
- checkbox全选与取消全选
- 全选与不全选的切换
- js实现简单的checkbox全选和取消全选效果
- 页面checkbox全选
- Javascript实现CheckBox的全选与取消全选的代码
- Javascript实现CheckBox的全选与取消全选的代码
- HDU1026
- input Button使用小技巧
- 使用ctags出现的问题
- xinit启动X Window System过程初探
- 用短信进行分享一段文字
- CheckBox的全选与不全选(刷新页面效果)
- CheckBox全选与不全选(不用刷新页面)
- 注册页面完成。自动给所有邮箱发送激活邮件
- Format of Index Blocks【每日一译】--20121214
- Mysql Java 连接指导
- 在 javascript 中,为什么 [1,2] + [3,4] 不等于 [1,2,3,4]?
- java 内存检测工具
- 省市县三级联动
- django中遇到的错误及解决方案