选中关于VS2005中GridView的自定义分页,单选、多选、排序、自增列的简单应用

gridview分页  时间:2021-02-11  阅读:()

关于VS2005中GridView的自定义分页单选、多选、排序、 自增列的简单应用。

多选时只有全部选中时“多选”才选中。

图片效果

简单示例代码如下fenpage.aspx的代码

.cs" Inherits="gridview_fenpage"%>

<!DOCTYPE html PUBLIC"-//W3C//DTDXHTML 1.0Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional .dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

>

//判断多选是否与选中项没有选中的返回false

)

{

)

{

++)

{

)

{

;

}

}

}

{

)

{

;

}

}

alert("请选择后再操作 ");

;

}

//鼠标经过改变行的颜色

)

{

;

;

}

)

{

{

;}

;

;

";

}

//

//多选的全选与取消

)

{

)

{

++){

;}

}

;

}

//

//只有全部选中时“全选”选中

()

{

;

;

)

{

++){

)

;

;

}

}

{

)

;

;

}

)

;

;

}

//

>

</head>

<body>

<form id="form1" runat="server">

<div>

<table cel lpadding="0" cel lspacing="0" border="0"width="80%" style="font-size: 11px">

<tr>

<td al ign="center">

<asp:GridView ID="GridView1" runat="server"Width="100%"Cel lPadding="4" ForeColor="#333333"

AutoGenerateColumns="False"Al lowPaging="True" PageSize="12" Borde rColor="Si lver"

BorderStyle="Sol id" BorderWidth="1px"OnRowDataBound="GridView1_RowDataBound"

ShowFooter="True" EmptyDataText="没有数据记录  "Al low

Sorting="True"OnSorting="GridView1_Sorting">

<Columns>

<asp:BoundField HeaderText="编号"DataField="id"Visible="False"/>

<asp:TemplateField HeaderText="&lt; input type='checkbox' id='chk' name='chk'oncl ick='checkJs(this.checked); ' /&gt;全选" FooterText="全选">

<ItemTemplate>

<input type="checkbox" id="checkboxname" name="checkboxname"value='<%# DataBinder.Eval(Container.DataItem, "id")%>' oncl ick='SingleCheckJs(); ' />

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="单选" FooterText="单选">

<ItemTemplate>

<input type="radio" id="RadioName" name="RadioName"value='<%#Eval("id")%>'/>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField HeaderText="自增列" FooterText="自增列">

<ItemTemplate>

()%>

</ItemTemplate>

</asp:TemplateField>

<asp:BoundField HeaderText="姓名" FooterText="姓名"DataField="name"SortExpression="name"/>

<asp:BoundField HeaderText="身份证号" FooterText="身份证号"DataField="card"SortExpression="card"/>

<asp:BoundField HeaderText="价格" FooterText="价格"DataField="price"DataFormatString="{0:#,##0.00}"

HtmlEncode="False"SortExpression="price"/>

<asp:BoundField HeaderText="数字" FooterText="数字"DataField="price"DataFormatString="{0:0.00}"

HtmlEncode="False"SortExpression="price"/>

<asp:BoundField HeaderText="建立时间" FooterText="建立时间"DataField="c reatedate"DataFormatString="{0:yyyy年M M月dd日 hh时mm分ss秒}"

HtmlEncode="False"SortExpression="createdate"/>

</Columns>

<RowStyle BackColor="#F7F6F3" ForeColor="#333333"/>

<EditRowStyle BackColor="#999999"/>

<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"/>

<PagerStyle BackColor="#284775" ForeColor="White"HorizontalAl ign="Center"/>

<AlternatingRowStyle BackColor="White" ForeColor="#284775"/>

<PagerSettings Visible="False"/>

<FooterStyle Font-Bold="True"/>

<HeaderStyle Font-Bold="False" Font-Ital ic="False"/>

</asp:GridView>

</td>

</tr>

<tr>

<td al ign="center" style="height: 25px">

<asp:LinkButton ID="btnFirst"CommandArgument="first"OnCl ick="PagerButtonCl ick"runat="server">首页</asp:LinkButton>

<asp:LinkButton ID="btnPrev"CommandArgument="prev"OnCl ick="PagerButtonCl ick" runat="server">上一页</asp:LinkButton>

<asp:LinkButton ID="btnNext"CommandArgument="next"OnCl ick="PagerButtonCl ick" runat="server">下一页</asp:LinkButton>

<asp:LinkButton ID="btnLast"CommandArgument="last"OnClick="PagerButtonCl ick" runat="server">尾页</asp:LinkButton>

<asp:Label ID="LblCurrentIndex" runat="server"></asp:Label>

<asp:Label ID="LblPageCount" runat="server"></asp:Label>

<asp:Label ID="LblRecordCount" runat="server"></asp:Label></td>

</tr>

<tr>

<td>

<asp:Button ID="Button2" runat="server"Text="checkbox得到选择的行"OnCl ick="Button2_Cl ick">

</asp:Button>

<asp:Button ID="Button1" runat="server"Text="radio得到选择的行"OnCl ick="Button1_Cl ick"></asp:Button>

</td>

</tr>

</table>

</div>

</form>

</body>

</html>fenpage.aspx.cs的代码using System;using System.Data;

using System.Configuration;using System.Col lections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Data.SqlCl ient;publ ic partial class gridview_fenpage : System.Web.UI.Page

{

)

{

); ";

("");

}

)

{

].ConnectionString;

;();

{

;

();

);

da.Fi l l(ds, "test01");

();

;

();

() +"页";

()+"页";()+"条";

)

{

;

;

;

;

;

;

;

}

)

{

;

;

;

;

}

易探云330元/年,成都4核8G/200G硬盘/15M带宽,仅1888元/3年起

易探云服务器怎么样?易探云是国内一家云计算服务商家,致力香港云服务器、美国云服务器、国内外服务器租用及托管等互联网业务,目前主要地区为运作香港BGP、香港CN2、广东、北京、深圳等地区。目前,易探云推出的国内云服务器优惠活动,国内云服务器2核2G5M云服务器低至330元/年起;成都4核8G/200G硬盘/15M带宽,仅1888元/3年起!易探云便宜vps服务器配置推荐:易探云vps云主机,入门型云...

ShineServers(5美元/月)荷兰VPS、阿联酋VPS首月五折/1核1G/50GB硬盘/3TB流量/1Gbps带宽

优惠码50SSDOFF 首月5折50WHTSSD 年付5折15OFF 85折优惠,可循环使用荷兰VPSCPU内存SSD带宽IPv4价格购买1核1G50G1Gbps/3TB1个$ 9.10/月链接2核2G80G1Gbps/5TB1个$ 12.70/月链接2核3G100G1Gbps/7TB1个$ 16.30/月链接3核4G150G1Gbps/10TB1个$ 18.10/月链接阿联酋VPSCPU内存SS...

TMThosting夏季促销:VPS月付7折,年付65折,独立服务器95折,西雅图机房

TMThosting发布了一个2021 Summer Sale活动,针对西雅图VPS主机提供月付7折优惠码,年付65折优惠码,独立服务器提供95折优惠码,本轮促销活动到7月25日。这是一家成立于2018年的国外主机商,主要提供VPS和独立服务器租用业务,数据中心包括美国西雅图和达拉斯,其中VPS基于KVM架构,都有提供免费的DDoS保护,支持选择Windows或者Linux操作系统。Budget ...

gridview分页为你推荐
邮箱怎么写正确的邮箱格式怎么写安装程序配置服务器失败sql安装程序配置服务器失败郭彩妮台灣有什麽新的電視劇?博客外链外链都要怎么做?博客外链有没有效果?pw美团网电话是什么pw网站运营刚创业的网站运营怎么做?中小企业信息化什么是企业信息化,应该这样实施直播加速怎么让已拍摄好的视频加速安装迅雷看看播放器迅雷看看播放器安装ejb开发什么是ejb?
vps交流 备案域名出售 老域名全部失效请记好新域名 budgetvm unsplash info域名 太原联通测速平台 服务器是干什么的 空间合租 跟踪路由命令 google台湾 双线asp空间 台湾google 稳定空间 asp空间 镇江高防服务器 亿库 优惠服务器 删除域名 comodo 更多