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

();

;

();

() +"页";

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

)

{

;

;

;

;

;

;

;

}

)

{

;

;

;

;

}

Dataideas:$1.5/月KVM-1GB/10G SSD/无限流量/休斯顿(德州)_主机域名

Dataideas是一家2019年成立的国外VPS主机商,提供基于KVM架构的VPS主机,数据中心在美国得克萨斯州休斯敦,主机分为三个系列:AMD Ryzen系列、Intel Xeon系列、大硬盘系列,同时每个系列又分为共享CPU和独立CPU系列,最低每月1.5美元起。不过需要注意,这家没有主页,你直接访问根域名是空白页的,还好他们的所有套餐支持月付,相对风险较低。下面以Intel Xeon系列共...

老薛主机VPS年付345元,活动进行时。

老薛主机,虽然是第一次分享这个商家的信息,但是这个商家实际上也有存在有一些年头。看到商家有在进行夏季促销,比如我们很多网友可能有需要的香港VPS主机季度及以上可以半价优惠,如果有在选择不同主机商的香港机房的可以看看老薛主机商家的香港VPS。如果没有记错的话,早年这个商家是主营个人网站虚拟主机业务的,还算不错在异常激烈的市场中生存到现在,应该算是在众多商家中早期积累到一定的用户群的,主打小众个人网站...

免费注册宝塔面板账户赠送价值3188礼包适合购买抵扣折扣

对于一般的用户来说,我们使用宝塔面板免费版本功能还是足够的,如果我们有需要付费插件和专业版的功能,且需要的插件比较多,实际上且长期使用的话,还是购买付费专业版或者企业版本划算一些。昨天也有在文章中分享年中促销活动。如今我们是否会发现,我们在安装宝塔面板后是必须强制我们登录账户的,否则一直有弹出登录界面,我们还是注册一个账户比较好。反正免费注册宝塔账户还有代金券赠送。 新注册宝塔账户送代金券我们注册...

gridview分页为你推荐
赵雨润电影《奇迹世界》详细剧情介绍iphone5解锁iphone5怎么解锁手机区号手机号码前怎样填写正确的国内区号?不兼容Google play 服务提示不兼容怎么办?qq空间装扮qq空间怎么装扮如何建立一个网站要建立一个网站怎么弄啊?蘑菇街美丽说蘑菇街、美丽说这类网站前期是怎么推广的?商标注册查询官网怎么查商标是否注册成功iphone6上市时间iphone6什么时候上市,价格是多少?什么是云平台什么是云平台管理软件,一个云平台软件应该具有哪些基本功能
siteground googleapps 国外私服 koss payoneer godaddy支付宝 天猫双十一秒杀 512m内存 北京双线机房 工作站服务器 腾讯实名认证中心 空间技术网 新睿云 linode支付宝 什么是web服务器 qq金券 114dns 可外链的相册 新疆服务器 新网dns 更多