GridView自定义分页导航

本文介绍了一个使用ASP.NET实现的合作商信息查询系统,重点展示了如何利用GridView进行批量删除、自定义分页、定位页码等功能,并实现了鼠标悬停时改变行背景色的效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自己做的一个项目中所运用到的技术:|

1. 日历控件(带时分秒)
2. GridView 批量删除,自定义分页,定位页码
3. GridView 修改
4. GridView 鼠标经过改变行的颜色
效果如下:
HTML:
<%@PageLanguage="C#"AutoEventWireup="true"CodeFile="StfCmpManager.aspx.cs"Inherits="StfCmpManager"%>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">
<headid="Head1"runat="server">
<title>合作商信息维护</title>
<scriptlanguage="javascript"type="text/javascript">
//判断多选是否与选中项(没有选中的返回false)
functionslcNo_click()
...{
if(document.form1.checkboxname.length)
...{
for(vari=0;i<document.form1.checkboxname.length;i++)
...{
if(document.form1.checkboxname[i].checked)
...{
returntrue;
}

}

}

else
...{
if(document.form1.checkboxname.checked)
...{
returntrue;
}

}

alert(
"请选择后再操作!");
returnfalse;
}


//鼠标经过改变行的颜色
if(!objbeforeItem)
...{
varobjbeforeItem
=null;
varobjbeforeItembackgroundColor
=null;
}

functionItemOver(obj)
...{
if(objbeforeItem)
...{
objbeforeItem.style.backgroundColor
=objbeforeItembackgroundColor;
}

objbeforeItembackgroundColor
=obj.style.backgroundColor;
objbeforeItem
=obj;
obj.style.backgroundColor
="#B9D1F3";
}

//

//多选的全选与取消
functioncheckJs(boolvalue)
...{
if(document.all.checkboxname.length>1)
...{
for(vari=0;i<document.all.checkboxname.length;i++)
...{
document.all.checkboxname[i].
checked=boolvalue;
}

}

else
document.all.checkboxname.
checked=boolvalue;
}

//

//只有全部选中时“全选”选中
functionSingleCheckJs()
...{
varflag1
=false;
varflag2
=false;

if(document.form1.checkboxname.length)
...{
for(vari=0;i<document.form1.checkboxname.length;i++)
...{
if(document.form1.checkboxname[i].checked)
flag1
=true;
else
flag2
=true;
}

}

else
...{
if(document.form1.checkboxname.checked)
flag1
=true;
else
flag2
=true;
}


if(flag1==true&&flag2==false)
document.getElementById(
"chk").checked=true;
else
document.getElementById(
"chk").checked=false;
}


</script>
<scripttype="text/javascript"language="javascript"src="Selecttime/calendar.js"></script>
</head>
<body>
<formid="form1"runat="server">
<tableid="Table10"cellSpacing="0"cellPadding="0"border="0"Style="z-index:103;
left:21px;position:absolute;top:20px;width:90%;">
<tr>
<tdbgColor="#fafafa">
<FIELDSETstyle="BORDER-RIGHT:#cccccc1pxsolid;BORDER-TOP:#cccccc1pxsolid;BORDER-LEFT:#cccccc1pxsolid;BORDER-BOTTOM:#cccccc1pxsolid;HEIGHT:45px"><LEGEND><FONTface="宋体"size="2">合作商查询</FONT></LEGEND>
<tableid="Table1"height="40"cellSpacing="0"cellPadding="0"width="100%"align="center"
border
="0">
<tr>
<tdheight="30"><FONTface="宋体">&nbsp;</FONT><FONTface="宋体">&nbsp;合作商名称
<asp:textboxid="TStfName"runat="server"BorderStyle="Groove"Width="144px"></asp:textbox>&nbsp;</FONT></td>
</tr>
<tr>
<tdstyle="height:30px">&nbsp;<FONTface="宋体">添加时间</FONT>
<asp:textboxid="StartTime"onfocus="setday(this)"runat="server"Width="159px"></asp:textbox>&nbsp;到
<asp:textboxid="EndTime"onfocus="setday(this)"runat="server"Width="160px"></asp:textbox>&nbsp;&nbsp;&nbsp;<FONTface="TimesNewRoman">&nbsp;&nbsp;&nbsp;</FONT></td>
</tr>
<TR>
<TDheight="30"><FONTface="宋体">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<FONTface="宋体">
<asp:buttonid="SelectClient"runat="server"Text="搜 索"onclick="SelectClient_Click"></asp:button>&nbsp;&nbsp;&nbsp;</FONT></FONT></TD>
</TR>
</table>
</FIELDSET>
</td>
</tr>
</table>
<tablecellpadding="0"cellspacing="0"border="0"Style="z-index:103;
left:21px;position:absolute;top:140px;width:90%;">
<trbgColor="#6B696B">
<tdalign="center"style="width:85%">
<asp:GridViewID="GridView1"runat="server"Width="100%"CellPadding="4"ForeColor="#333333"
AutoGenerateColumns
="False"AllowPaging="True"BorderColor="Silver"
BorderStyle
="Solid"BorderWidth="1px"OnRowDataBound="GridView1_RowDataBound"
ShowFooter
="false"EmptyDataText="没有数据记录!!"AllowSorting="True"OnSorting="GridView1_Sorting">
<Columns>
<asp:BoundFieldHeaderText="编号"DataField="id"Visible="False"/>
<asp:TemplateFieldHeaderText="&lt;inputtype='checkbox'id='chk'name='chk'onclick='checkJs(this.checked);'/&gt;全选">
<ItemTemplate>
<inputtype="checkbox"id="checkboxname"name="checkboxname"value='<%#DataBinder.Eval(Container.DataItem,"StfId")%>'onclick='SingleCheckJs();'/>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateFieldHeaderText="序号">
<ItemTemplate>
<%#(Container.DataItemIndex+1).ToString()%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateFieldHeaderText="充值">
<ItemTemplate>
<%#GetClientVisitInfoShowCmpMoney(DataBinder.Eval(Container.DataItem,"StfId"),DataBinder.Eval(Container.DataItem,"StfName"))%>
</ItemTemplate>
</asp:TemplateField>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值