首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

AspNetPager+updatepanel以postback方式回传有关问题,第一页有反应,第二页点了不刷新了

2012-01-07 
AspNetPager+updatepanel以postback方式回传问题,第一页有反应,第二页点了不刷新了HTML codeasp:UpdatePa

AspNetPager+updatepanel以postback方式回传问题,第一页有反应,第二页点了不刷新了

HTML code
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"         style="width:566px; float:left;" ClientIDMode="AutoID"         ViewStateMode="Enabled">        <ContentTemplate>            <asp:Repeater ID="adlistRP" runat="server" ViewStateMode="Enabled" OnItemCommand="adlistRP_ItemCommand" >               <ItemTemplate>                 <div class="content">                   <asp:Image ID="Image1"  ImageUrl='<%#Eval("ss_pic") %>' runat="server" style="margin:5px;width:60px;height:60px;float:left;" />                   <div style="width:490px;float:right">                   <div style="margin:5px 0;width:490px;float:right;">                     <a><%#Eval("ss_name") %>:</a><%#Eval("ad_word") %><%#Eval("ad_id") %></div>                   <div style="float:right;width:490px;height:25px;">                       <div style="width:40px;height:25px;float:right; padding-left:3px; border-left:1px solid #dddddd; ">                       <asp:Button ID="Button2" CommandName="1" CommandArgument='<%#Eval("ad_id")%>' runat="server" Text="评论" style="background-color:white; border: 0px; height:28px; cursor:pointer;" /></div>                   </div></div>                                      <asp:UpdatePanel runat="server" ID="UPLL" UpdateMode="Conditional" Visible="true" ViewStateMode="Enabled">                      <ContentTemplate>                      <div style="float:right; width:490px; background-color:#ECEFF5; margin-top:13px;">                         <asp:Label ID="LBL" runat="server" Text="waiting" Visible="false" ></asp:Label>                         <asp:Image ID="Image2" runat="server"  style="float:left; width:40px; height:40px; margin:5px;" />                         <asp:TextBox ID="comment" runat="server"  TextMode="MultiLine" style="float:left; margin:5px 0; width:420px; height:80px; overflow:hidden;"></asp:TextBox>                         <asp:Button ID="Do_comment"  CommandName="comment" CommandArgument='<%#Eval("ad_id")%>' runat="server" Text="评论"          ForeColor="White" class="button" style="float:right;"/>                      </div>                                                  <asp:Repeater ID="commentlist" runat="server" ViewStateMode="Enabled">                            <ItemTemplate>                            <div style="float:right; width:490px; background-color:#ECEFF5; margin-top:2px;">                              <asp:Image ID="Image3" runat="server" style="float:left; width:40px; height:40px; margin:5px;" />                              <div style="float:left; width:420px; margin:10px 0;">                              <div style="float:left; width:420px; font-size:small;"><%#Eval("com_content")%></div>                              <div style="float:left; width:420px; font-size:small;">用户名 评论时间</div>                              </div>                            </div>                            </ItemTemplate>                         </asp:Repeater>                                                                </ContentTemplate>                      <Triggers>                         <asp:AsyncPostBackTrigger ControlID="adlistRP" />                      </Triggers>                                      </asp:UpdatePanel>                                  </div>               </ItemTemplate>            </asp:Repeater>                   </ContentTemplate>        <Triggers>            <asp:AsyncPostBackTrigger ControlID="DropDownList1" />        </Triggers>    </asp:UpdatePanel>    <asp:UpdatePanel ID="pagex" UpdateMode="Conditional" runat="server"         style="float:left;clear:left;" ViewStateMode="Enabled">    <ContentTemplate>        <webdiyer:AspNetPager ID="AspNetPager1" runat="server" Width="610px" FirstPageText="第一页"          LastPageText="最后一页" NextPageText="下一页" PrevPageText="上一页" Font-Names="Arial"             BackColor="#F8B500" AlwaysShow="true"           ShowInputBox="Always" SubmitButtonText="转到" SubmitButtonStyle="botton"             OnPageChanging="pageBind_PageChanging" ForeColor="Black"          HorizontalAlign="Center" PageSize="10"          style="font-size: 12px; color: #0099ff; background-color: #ffffff; text-decoration: none"          UrlPaging="false" InvalidPageIndexErrorMessage="请请输入正确的页码!"             ShowNavigationToolTip="True" TextAfterInputBox="页" TextBeforeInputBox="第"             PageIndexBoxType="DropDownList" PageIndexOutOfRangeErrorMessage="请请输入正确的页码!"             ShowPageIndexBox="Always" ViewStateMode="Enabled" >    </webdiyer:AspNetPager></ContentTemplate>    <Triggers><asp:AsyncPostBackTrigger ControlID="DropDownList1" /></Triggers>    </asp:UpdatePanel> 


C# code
    protected string rank { get; set; }    protected string free { get; set; }    protected void Page_Load(object sender, EventArgs e)    {        if (!IsPostBack)        {            rank = "select * from adlist where ad_top='N'";            free = "select * from adlist where ad_top='Y'";            BindData(rank, free);        }            }    //数据绑定    protected void BindData(string rank,string free)    {        DBaction db = new DBaction();        DataTable dt1 = db.Select(rank);//获取排名广告        DataTable dt2 = db.Select(free);//获取免费广告        DataTable dt = new DataTable();        dt = dt1;        dt.Merge(dt2);//将排名广告与免费广告何为一张表        AspNetPager1.PageSize = 10;        DataTable list = dt.Clone();                int LastSize=AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1)+AspNetPager1.PageSize-1;        if (LastSize > dt.Rows.Count - 1) { LastSize = dt.Rows.Count - 1; }                for (int i = AspNetPager1.PageSize * (AspNetPager1.CurrentPageIndex - 1); i <= LastSize; i++)         {            list.Rows.Add(dt.Rows[i].ItemArray);        }        DataSet ds = new DataSet();        ds.Tables.Add(list);        AspNetPager1.RecordCount = dt.Rows.Count;        adlistRP.DataSource = ds.Tables[0];        adlistRP.DataBind();    }    protected void pageBind_PageChanging(object src, PageChangingEventArgs e)    {        AspNetPager1.CurrentPageIndex = e.NewPageIndex;        BindData(rank,free);    }    



按照上面这样的写法分页,第一页可以显示,但是点击其他页不会动了~

[解决办法]
UpdatePanel 内的控件对postback会存在支持问题.
你把你触发 postback 事件的控件RegisterPostBackControl 标记一下试试

热点排行