.NET中使用GridView控件,再用模版做分页功能,可是在浏览器中显示不出中所有的控件
前台代码如下:
<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>