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

();

;

();

() +"页";

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

)

{

;

;

;

;

;

;

;

}

)

{

;

;

;

;

}

Hosteons:新上1Gbps带宽KVM主机$21/年起,AMD Ryzen CPU+NVMe高性能主机$24/年起_韩国便宜服务器

我们在去年12月分享过Hosteons新上AMD Ryzen9 3900X CPU及DDR4内存、NVMe硬盘的高性能VPS产品的消息,目前商家再次发布了产品更新信息,暂停新开100M带宽KVM套餐,新订单转而升级为新的Budget KVM VPS(SSD)系列,带宽为1Gbps端口,且配置大幅升级,目前100M带宽仅保留OpenVZ架构产品可新订购,所有原有主机不变,用户一直续费一直可用。Bud...

rfchost:洛杉矶vps/双向CN2 GIA,1核/1G/10G SSD/500G流量/100Mbps/季付$23.9

rfchost怎么样?rfchost是一家开办了近六年的国人主机商,一般能挺过三年的国人商家,还是值得入手的,商家主要销售VPS,机房有美国洛杉矶/堪萨斯、中国香港,三年前本站分享过他家堪萨斯机房的套餐。目前rfchost商家的洛杉矶机房还是非常不错的,采用CN2优化线路,电信双程CN2 GIA,联通去程CN2 GIA,回程AS4837,移动走自己的直连线路,目前季付套餐还是比较划算的,有需要的可...

vdsina:俄罗斯VPS(datapro),6卢布/天,1G内存/1核(AMD EPYC 7742)/5gNVMe/10T流量

今天获得消息,vdsina上了AMD EPYC系列的VDS,性价比比较高,站长弄了一个,盲猜CPU是AMD EPYC 7B12(经过咨询,详细CPU型号是“EPYC 7742”)。vdsina,俄罗斯公司,2014年开始运作至今,在售卖多类型VPS和独立服务器,可供选择的有俄罗斯莫斯科datapro和荷兰Serverius数据中心。付款比较麻烦:信用卡、webmoney、比特币,不支持PayPal...

gridview分页为你推荐
外网和内网内网和外网有什么区别啊?淘宝收费淘宝要收费吗?pwlosera,pw是什么,是不认识的人发的短信。请解释::如何建立自己的网站怎么创建自己的网站godaddy美国GODADDY 域名支持域名别名解析吗?淘宝网页显示不正常淘宝网页不能正常显示ejb开发什么是EJB?它是干什么的?和JAVA,JSP有关系吗?他们各有什么特点和用途?2012年正月十五农历2012年正月15早上9点多生的!命里缺什么!是什么命相宕机人们说的宕机是什么意思iphone6上市时间苹果6是什么时候出的 ?
域名解析 免费域名申请 动态域名解析软件 hostmaster 128m内存 美国主机论坛 windows2003iso 个人空间申请 优酷黄金会员账号共享 免费的asp空间 什么是web服务器 帽子云排名 金主 域名转入 如何登陆阿里云邮箱 广州服务器托管 小夜博客 香港ip cx域名 godaddy域名 更多