.NET中使用GridView控件,再用模版做分页功能,可是在浏览器中显示不出中所有的控件

xiaowaiyuan 2012-07-14 11:29:08
前台代码如下:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
Height="111px" Width="764px" OnRowDataBound="GridView1_RowDataBound" OnSelectedIndexChanged="GridView1_SelectedIndexChanged"
OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" OnRowCancelingEdit="GridView1_RowCancelingEdit"
PageSize="8" OnPageIndexChanging="GridView1_PageIndexChanging" AllowSorting="True"
align="center" Style="text-align: center" AllowPaging="True">
<Columns>
<asp:TemplateField HeaderText="选择">
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server" OnClick="checkbox_onchange()" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="序号">
<ControlStyle Width="30px" />
<EditItemTemplate>
<asp:TextBox ID="edID" runat="server" Text='<%# Bind("RolesId") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbID" runat="server" Text='<%# Bind("RolesId") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtID" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="角色">
<ControlStyle Width="100px" />
<EditItemTemplate>
<asp:DropDownList ID="edRolesName" runat="server" DataSourceID="SqlDataSource1" DataTextField="RolesName"
DataValueField="RolesId" AutoPostBack="True" AppendDataBoundItems="True">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lbRolesName" runat="server" Text='<%# Bind("RolesName") %>'></asp:Label>
</ItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtRolesName" runat="server" Width="100px"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="编辑" ShowEditButton="True" ControlStyle-ForeColor="Red">
<ControlStyle ForeColor="Red"></ControlStyle>
</asp:CommandField>
</Columns>
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" CssClass="gvRow" />
<EditRowStyle BorderColor="Red" Font-Underline="False" ForeColor="Red" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" CssClass="gvHeader" />
<AlternatingRowStyle BackColor="#F7F7F7" CssClass="gvAlternatingRow" />
<PagerTemplate>
<table width="100%">
<tr>
<td align="left">
<asp:Button ID="btnFirst" runat="server" Text="首 页" Height="20px" CssClass="buttonup2"
OnClick="btnFirst_Click" UseSubmitBehavior="False" onmouseout="this.style.background ='url(images/mouseup2.jpg)'"
onmouseover="this.style.background ='url(images/mousedown2.jpg)'" />
<asp:Button ID="btnPre" runat="server" Text="上一页" Height="20px" CssClass="buttonup2"
OnClick="btnPre_Click" UseSubmitBehavior="False" onmouseout="this.style.background ='url(images/mouseup2.jpg)'"
onmouseover="this.style.background ='url(images/mousedown2.jpg)'" />
<asp:Button ID="btnNext" runat="server" Text="下一页" Height="20px" CssClass="buttonup2"
OnClick="btnNext_Click" UseSubmitBehavior="False" onmouseout="this.style.background ='url(images/mouseup2.jpg)'"
onmouseover="this.style.background ='url(images/mousedown2.jpg)'" />
<asp:Button ID="btnLast" runat="server" Text="尾 页" Height="20px" CssClass="buttonup2"
OnClick="btnLast_Click" UseSubmitBehavior="False" onmouseout="this.style.background ='url(images/mouseup2.jpg)'"
onmouseover="this.style.background ='url(images/mousedown2.jpg)'" />
</td>
<td align="center">
当前第<asp:Label ID="LblPage" runat="server" Style="text-align: center" Text='<%# GridView1.PageIndex + 1%>'></asp:Label>
页/共<asp:Label ID="LblTotalPage" runat="server" Style="text-align: center;" Text='<%# GridView1.PageCount %>'></asp:Label>

<%--<asp:Label ID="lblCurrentPage" Height="20px" runat="server" Text="Label"></asp:Label>--%>
<asp:Label runat="server" Height="20px" Text="跳转到第"></asp:Label>
<asp:DropDownList Height="20px" ID="ddlCurrentPage" runat="server" AutoPostBack="True"
OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
<asp:Label ID="Label1" runat="server" Height="20px" Text="页"></asp:Label>
</td>
<td align="right">
<asp:CheckBox ID="CheckBox2" runat="server" Height="20px" OnCheckedChanged="CheckBox2_CheckedChanged"
Text="全选" AutoPostBack="True" />
<asp:Button ID="btnAdd" runat="server" Height="20px" Text="添加角色" CssClass="buttonup4"
OnClick="btnAdd_Click" UseSubmitBehavior="False" onmouseout="this.style.background ='url(images/mouseup4.jpg)'"
onmouseover="this.style.background ='url(images/mousedown4.jpg)'" />
<asp:Button ID="btnSave" runat="server" Height="20px" Text="提 交" CssClass="buttonup2"
OnClick="btnSave_Click" UseSubmitBehavior="False" onmouseout="this.style.background ='url(images/mouseup2.jpg)'"
onmouseover="this.style.background ='url(images/mousedown2.jpg)'" />
<asp:Button ID="btnDelete" runat="server" Height="20px" Text="删 除" OnClick="btnDelete_Click"
CssClass="buttonup2" OnClientClick="return confirm('确认修改提交吗?')" onmouseout="this.style.background ='url(images/mouseup2.jpg)'"
onmouseover="this.style.background ='url(images/mousedown2.jpg)'" />
<asp:Button ID="btnCancle" runat="server" Height="20px" Text="取 消" OnClick="btnCancle_Click"
UseSubmitBehavior="False" CssClass="buttonup2" onmouseout="this.style.background ='url(images/mouseup2.jpg)'"
onmouseover="this.style.background ='url(images/mousedown2.jpg)'" />
</td>
</tr>
</table>
</PagerTemplate>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TPHConnectionString %>"
SelectCommand="SELECT * FROM [TPH_Roles]"></asp:SqlDataSource>
</div>
...全文
216 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dotar 2013-08-06
  • 打赏
  • 举报
回复
PageSize="8" 你的数据有8行?
sunyanjuan1981 2013-08-06
  • 打赏
  • 举报
回复
结果集够8行?

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧