CheckBox全选与不全选(不用刷新页面)
来源:互联网 发布:发布淘宝类目如何选择 编辑:程序博客网 时间:2024/05/01 11:01
aspx文件:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="wangyibushuaxinyemian.aspx.cs" Inherits="_12._18zuoye.wangyibushuaxinyemian" %>
<!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>
<script language="javascript" type="text/javascript">
// <![CDATA[
function change(sender) {
var table = document.getElementById("GridView1");
for (var i = 1; i < table.rows.length; i++) {
table.rows[i].cells[0].getElementsByTagName("input")[0].checked = sender.checked;
}
}
// ]]>
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="sid" DataSourceID="SqlDataSource1">
<Columns>
<asp:TemplateField>
<HeaderTemplate>
<input id="Checkbox2" type="checkbox" onclick="return change(this)" />
</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>
<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文件样式:
Web.config文件:
<?xml version="1.0" encoding="utf-8"?>
<!--
有关如何配置 ASP.NET 应用程序的详细消息,请访问
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<connectionStrings>
<add name="studentConnectionString" connectionString="Data Source=PC;Initial Catalog=student;User ID=sa;Password=linlin"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.0" />
</system.web>
</configuration>
- CheckBox全选与不全选(不用刷新页面)
- CheckBox的全选与不全选(刷新页面效果)
- JS checkbox 全选与不全选
- 全选与不全选
- 全选与不全选
- checkbox全选与取消全选
- checkbox全选与取消全选
- 页面checkbox全选
- 实现全选和取消全选(JavaScript控制CheckBox 的全选与取消全选)
- checkbox的全选和不全选
- checkbox全选与注销
- checkbox全选与全不选
- CheckBox全选与反转
- JavaScript - CheckBox 全选与取消全选
- checkbox的全选与取消全选
- 提供 CheckBox 全选与取消全选程序
- input checkbox 全选与取消全选
- javascript CheckBox 全选与取消全选
- 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中遇到的错误及解决方案
- objective-c中的构造函数(对象初始化)(七)