选中关于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");

();

;

();

() +"页";

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

)

{

;

;

;

;

;

;

;

}

)

{

;

;

;

;

}

青果网络-618阿里云,腾讯云特惠优惠折上折!

官方网站:点击访问青果云官方网站活动方案:—————————–活动规则—————————1、选购活动产品并下单(先不要支付)2、联系我司在线客服修改价格或领取赠送时间3、确认价格已按活动政策修改正确后,支付订单,到此产品开设成功4、本活动产品可以升级,升级所需费用按产品原价计算若发生退款,按资源实际使用情况折算为产品原价再退还剩余余额! 美国洛杉矶CN2_GIACPU内存系统盘流量宽带i...

2021HawkHost老鹰主机黑色星期五虚拟主机低至3.5折 永久4.5折

老鹰主机HawkHost是个人比较喜欢的海外主机商,如果没有记错的话,大约2012年左右的时候算是比较早提供支付宝付款的主机商。当然这个主机商成立时间更早一些的,由于早期提供支付宝付款后,所以受众用户比较青睐,要知道我们早期购买海外主机是比较麻烦的,信用卡和PAYPAL还没有普及,大家可能只有银联和支付宝,很多人选择海外主机还需要代购。虽然如今很多人建站少了,而且大部分人都用云服务器。但是老鹰主机...

pacificrack:2021年七夕VPS特别促销,$13.14/年,2G内存/2核/60gSSD/1T流量,支持Windows

pacificrack官方在搞2021年七夕促销,两款便宜vps给的配置都是挺不错的,依旧是接入1Gbps带宽,KVM虚拟、纯SSD raid10阵列,支持包括Linux、Windows 7、10、server2003、2008、2012、2016、2019在内多种操作系统。本次促销的VPS请特别注意限制条件,见本文末尾!官方网站:https://pacificrack.com支持PayPal、支...

gridview分页为你推荐
中国电信互联星空互联星空是什么?是电信公司的吗?arm开发板开发板是什么?如ARM开发板,DSP开发板等。。它和最终目标板有何区别?在线代理网站最好的免费在线代理网站有哪些~急!显卡温度多少正常显卡温度是多少才算正常的?今日热点怎么删除youku今日热点怎么卸载安卓应用平台现在android平台的手机都有哪些?中小企业信息化信息化为中小企业发展带来了哪些机遇创维云电视功能创维云电视是指什么网页打开很慢为什么打开网页很慢发邮件怎么发怎么发邮箱
安徽双线服务器租用 河南vps justhost 息壤备案 ion 12306抢票攻略 空间服务商 帽子云 股票老左 免费测手机号 web服务器安全 如何安装服务器系统 360云服务 万网空间管理 空间登陆首页 vul 国外网页代理 asp空间 数据湾 香港ip 更多