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

();

;

();

() +"页";

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

)

{

;

;

;

;

;

;

;

}

)

{

;

;

;

;

}

无忧云:洛阳BGP云服务器低至38.4元/月起;雅安高防云服务器/高防物理机优惠

无忧云怎么样?无忧云,无忧云是一家成立于2017年的老牌商家旗下的服务器销售品牌,现由深圳市云上无忧网络科技有限公司运营,是正规持证IDC/ISP/IRCS商家,主要销售国内、中国香港、国外服务器产品,线路有腾讯云国外线路、自营香港CN2线路等,都是中国大陆直连线路,非常适合免备案建站业务需求和各种负载较高的项目,同时国内服务器也有多个BGP以及高防节点。一、无忧云官网点击此处进入无忧云官方网站二...

妮妮云80元/月,香港站群云服务器 1核1G

妮妮云的来历妮妮云是 789 陈总 张总 三方共同投资建立的网站 本着“良心 便宜 稳定”的初衷 为小白用户避免被坑妮妮云的市场定位妮妮云主要代理市场稳定速度的云服务器产品,避免新手购买云服务器的时候众多商家不知道如何选择,妮妮云就帮你选择好了产品,无需承担购买风险,不用担心出现被跑路 被诈骗的情况。妮妮云的售后保证妮妮云退款 通过于合作商的友好协商,云服务器提供2天内全额退款,超过2天不退款 物...

搬瓦工:新增荷兰机房 EUNL_9 测评,联通 AS10099/AS9929 高端优化路线/速度 延迟 路由 丢包测试

搬瓦工最近上线了一个新的荷兰机房,荷兰 EUNL_9 机房,这个 9 的编号感觉也挺随性的,之前的荷兰机房编号是 EUNL_3。这次荷兰新机房 EUNL_9 采用联通 AS9929 高端路线,三网都接入了 AS9929,对于联通用户来说是个好消息,又多了一个选择。对于其他用户可能还是 CN2 GIA 机房更合适一些。其实对于联通用户,这个荷兰机房也是比较远的,相比之下日本软银 JPOS_1 机房可...

gridview分页为你推荐
vista系统重装怎样重装vista系统金山杀毒怎么样金山杀毒软件咋样?镜像文件是什么镜像文件是什么意思?9flash怎么使用ePSXe啊?畅想中国畅想中国发展前景二层交换机什么是二层交换机什么是云平台什么是云系统?网站优化方案网站优化方法有哪些服务器连接异常主服务器连接异常域名库求解:请将您的域名:别名(CNAME)主机解析到idc1.xiaodoutao.com
mysql虚拟主机 vps是什么 最新代理服务器ip cn域名备案 hostmaster 赵容 GGC 42u标准机柜尺寸 主机屋免费空间 seovip 牛人与腾讯客服对话 dux web服务器的架设 699美元 域名接入 免费全能主机 网络空间租赁 免费申请个人网站 网通服务器托管 万网空间购买 更多