AspNetPager+updatepanel以postback方式回传问题,第一页有反应,第二页点了不刷新了
<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>
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); }