enter code here
我正在构建用户控件以使用寻呼机显示列表视图中的项目。如果我只有一个用户控件(SharePoint 2010 webpart),则完全可以使用以下代码:
ASCX:
<asp:ListView ID="ListView" runat="server">
<LayoutTemplate>
<table id="table">
<tr id="tableRow">
<td id="column1" class="tableCell">
<div runat="server" id="itemPlaceholder">
</div>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
...
</ItemTemplate>
</asp:ListView>
<div class="pager">
<asp:DataPager ID="DataPager" PagedControlID="ListView" runat="server">
<Fields>
<asp:NextPreviousPagerField ShowFirstPageButton="False" ShowNextPageButton="False"
ShowPreviousPageButton="true" PreviousPageText="<" RenderDisabledButtonsAsLabels="True" />
<asp:NumericPagerField />
<asp:NextPreviousPagerField ShowLastPageButton="False" ShowPreviousPageButton="False"
ShowNextPageButton="true" NextPageText=">" RenderDisabledButtonsAsLabels="True" />
</Fields>
</asp:DataPager
</div>
代码背后:
DataPager.PageSize = X;
ListView.DataSource = items.ToList();
ListView.DataBind();
问题是当我在我的页面上放置其中两个ascx时,所有项目都会转到第一个listview:当然因为它们没有不同的ID。但是我怎么能给他们一个不同的ID,因为我事先不知道我将拥有多少个用户控件?
答案 0 :(得分:0)
您必须更改用户控件的客户端ID模式以及该控件内的子控件........
使用此
ClientIDMode="AutoID"