日期:2014-05-18  浏览次数:20447 次

gridview 分页 问题
用结合ajax control toolket的控件 做了个搜索页面,,根据不同的类别,因为每个目标数据库表的结构不一样所以,用了3个gridview控件,分别来显示这3个类别的搜索结果,结果gridview控件分页出现问题

前台代码
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="SearchResult.aspx.cs" Inherits="SearchResult" Title="搜索结果页" Theme="typical"%>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  <asp:ScriptManagerProxy id="ScriptManagerProxy1" runat="server">
  </asp:ScriptManagerProxy>
  <div class="bodydiv01" id="searchdivbox">
  <div class="searchheader">
  关键字: <asp:TextBox ID="txtKeyword" runat="server"></asp:TextBox>
  &nbsp; &nbsp;&nbsp;
  类别:
  <asp:DropDownList ID="DropDownList1" runat="server">
  <asp:ListItem Selected="True" Value="articles">文章</asp:ListItem>
  <asp:ListItem Value="downloads">下载资源</asp:ListItem>
  <asp:ListItem Value="links">链接</asp:ListItem>
  </asp:DropDownList>
  &nbsp;&nbsp; 每页条数:<asp:TextBox ID="txtNum" runat="server"></asp:TextBox>
  &nbsp; &nbsp;
  <asp:Button ID="Button1" runat="server" Text="立刻搜索" OnClick="Button1_Click" /> [/color[color=#0000FF]]//此处点击后可以显示数据,分页器也能显示,只是点击 页码 1以后的页码,页面gridview就为空了
  <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtKeyword"
  Display="None" ErrorMessage="请输入搜索关键字"></asp:RequiredFieldValidator>
  <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtNum"
  Display="None" ErrorMessage="请输入一个1到25的整数"></asp:RequiredFieldValidator>
  <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="txtNum"
  ErrorMessage="RangeValidator" MaximumValue="25" MinimumValue="1" Type="Integer"></asp:RangeValidator>
   
   
  </div>

  <asp:UpdatePanel id="UpdatePanel1" runat="server" UpdateMode="Conditional">
  <contenttemplate>
<asp:GridView id="ArtilceView" runat="server" GridLines="None" Visible="False" ShowHeader="False" AllowPaging="True" AutoGenerateColumns="False" Width="100%" __designer:wfdid="w8" OnPageIndexChanging="ArtilceView_PageIndexChanging"><Columns>
<asp:TemplateField><ItemTemplate>
  <ul class="searchresult">
  <li class="resultheader"><a href='<%# "Articles/"+Eval("ArticleID").ToString()+".shtml" %>'><%# Eval("title").ToString() %></a></li>
  <li class="resultcontent"><span class="zhaiyao">摘要:</span><%# Eval("Abstract