日期:2014-05-17  浏览次数:20523 次

GridView 绑数据,重新查询后不能回到第1页
前端代码:
HTML code

 <div class="searchlayer" id="searchdiv" runat="server">
                    链接文本:<asp:TextBox ID="txtbtitle" runat="server"></asp:TextBox>  系统类型:<asp:DropDownList ID="dropType" runat="server" AutoPostBack="false">
                        </asp:DropDownList>   IP段/分局:<asp:DropDownList ID="dropIP" runat="server" AutoPostBack="false">
                        </asp:DropDownList>
                    <br />
                    <asp:ImageButton ID="ibtnAdd" ImageUrl="~/App_Themes/Default/Images/btn_search.gif"
                        ImageAlign="AbsMiddle" runat="server" OnClick="btnsearch_Click" />
                    &nbsp;
                    <asp:ImageButton ID="ibtnReset" ImageUrl="~/App_Themes/Default/Images/btn_reset.gif"
                        ImageAlign="AbsMiddle" runat="server" OnClick="btnReset_Click" />
                    <span style="margin: 5px;">
                        <img src="App_Themes/Default/Images/icon_08.gif" alt="添加新的链接" />
                        <a style="color: #000;" href="addLink.aspx">添加链接</a></span>
                </div>
            </center>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnPageIndexChanging="GridView1_PageIndexChanging"
                OnPageIndexChanged="GridView1_PageIndexChanged" AllowPaging="true" PageSize="14"
                Width="850">
                <FooterStyle BackColor="#FFFFFF" Font-Bold="True" ForeColor="White" />
                <Columns>
                    <asp:TemplateField HeaderText="ID" ItemStyle-Width="50px">
                        <ItemTemplate>
                            <asp:Label ID="Labelid" runat="server" Text='<%# Bind("id") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="系统名称" ItemStyle-Width="300px">
                        <ItemTemplate>
                            <asp:Label ID="Labeltile" runat="server" Text='<%# Bind("title") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="链接地址" ItemStyle-Width="400px">
                        <ItemTemplate>
                            <a style="color: #000;" href="<%# Eval("url") %>" target="_blank">
                                <asp:Label ID="Labelurl" runat="server" Text='<%# myleft(Eval("url").ToString(),40)  %>'
                                    ToolTip='<%# Eval("url") %>'></asp:Label></a>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="IP段/分局" ItemStyle-Width="250px">
                        <ItemTemplate>
                            <asp:Label ID="Labelip" runat="server" Text='<%# Eval("ip")+" / "+IPtoText(Eval("ip").ToString()) %>'></asp:Label>
                        </It