.ascx文件是不是动态加上去的,翻页的时候状态不能保持,需要在翻页的代码里也编程加入.ascx

解决方案 »

  1.   

    而且分页的代码是在.ascx里写的
      

  2.   

    需要把翻页的时间提供给引用控件的页面,把datalist也再绑定一次
      

  3.   

    http://www.codeproject.com/aspnet/masterdetailgrid/masterdetailgrid_src.zip
    http://xml.sz.luohuedu.net/xml/Content.asp 
    http://aspalliance.com/Colt/Articles/Article3.aspx
    http://xml.sz.luohuedu.net/xml/ShowList.asp?id=1
      

  4.   

    请多指点些,俺认为不可能是DataList没有把翻页前的状态保存或没有传给用户控件,因为把这个.ascx的用户控件直接放在页面上则没有问题。放在DataList中就不行了。
      

  5.   

    写错了,应是有可能是DataList没有把翻页前的状态保存或没有传给用户控件
      

  6.   

    分页的代码很简单,就是用DataGrid的分页模板作的.
      

  7.   

    det_list.aspx的代码
    <%@Register Tagprefix="acme" TagName="det_list" src="acme/det_list.ascx"%><asp:datalist id="list_sub" runat="server" BorderWidth="1" GridLines="Both">
         <ItemTemplate> <acme:det_list id="mycontrol" lmid='<%# DataBinder.Eval(Container.DataItem,"id")%>' pl=3 lmmc='<%# Trim(DataBinder.Eval(Container.DataItem,"mc"))%>' pgsize="4" Runat="server">
    </acme:det_list>
      </ItemTemplate>
    </asp:datalist>det_list.ascs的代码
    <asp:table id="att" Runat="server" CellSpacing="0" CellPadding="0" Width="100%">
    <asp:TableRow>
    <asp:TableCell></asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
    <asp:TableCell>
    <asp:datagrid id="d_list" runat="server">
    <Columns>
    <asp:TemplateColumn>
    <ItemStyle Width="10px"></ItemStyle>
    <ItemTemplate>
    <%list()%>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <ItemTemplate>
    <a href='display.aspx?id=<%# DataBinder.Eval(Container.DataItem,"id")%>' target="_blank">
    <%# intercept(DataBinder.Eval(Container.DataItem,"bt"),10)%>
    </a>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <ItemTemplate>
    <%# DataBinder.Eval(Container.DataItem,"sj").ToShortDateString()%>
    </ItemTemplate>
    </asp:TemplateColumn>
    <asp:TemplateColumn>
    <ItemTemplate>
    <%# imgnew(DataBinder.Eval(Container.DataItem,"sj"))%>
    </ItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </asp:datagrid>
    </asp:TableCell>
    </asp:TableRow>
    </asp:table>det_list.ascx.vb中分页代码
     Private Sub d_list_page()                                   '分页
            d_list.AllowPaging = True
            'd_list.AllowCustomPaging = True
            d_list.PagerStyle.Mode = PagerMode.NumericPages
            d_list.PagerStyle.Position = PagerPosition.Bottom
            d_list.PagerStyle.HorizontalAlign = HorizontalAlign.Right
            d_list.PageSize = pgsize
            d_list.PagerStyle.PageButtonCount = 5
        End Sub    Private Sub d_list_PageIndexChanged(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridPageChangedEventArgs) Handles d_list.PageIndexChanged
            d_list.CurrentPageIndex = e.NewPageIndex
            d_list.DataBind()
        End Sub
      

  8.   

    d_list.DataBind()前,重新制定一下他的datascorce试试