Pergunta

Eu tenho um aplicativo personalizado de página que eu criei uma fortemente personalizado DFWP (usando jQuery e o Kendo UI), mas eu gostaria de reutilizá-lo através de 4 diferentes listas.Como posso alterar dinamicamente o ListID associados com a parte da web?

Foi útil?

Solução

Eu mudei o DFWP marcação para o seguinte (olhar para <%# listId %> e QueryString(ID))

<WebPartPages:WebPartZone runat="server" FrameType="None" ID="WebPartZone1" Title="loc:Main"><ZoneTemplate>
        <WebPartPages:DataFormWebPart runat="server" Description="" ID="DFWP1"
            PartOrder="2" Default="FALSE" HelpLink="" AllowRemove="True" 
            IsVisible="True" AllowHide="False" UseSQLDataSourcePaging="True" ExportControlledProperties="True"
            DataSourceID="" Title="MarketNeed" ViewFlag="8" NoDefaultStyle="TRUE" AllowConnect="True" DisplayName="MarketNeed" PageType="PAGE_NEWFORM" 
            FrameState="Normal" PageSize="-1" PartImageLarge="" AsyncRefresh="False" ExportMode="All" Dir="Default" DetailLink="" ShowWithSampleData="False" 
            ListId="<%# listId %>" 
            ListName="<%# listId %>" FrameType="None" PartImageSmall="" IsIncluded="True" 
            SuppressWebPartChrome="False" AllowEdit="True" ManualRefresh="False" ChromeType="None" AutoRefresh="False" AutoRefreshInterval="60" AllowMinimize="True"
             ViewContentTypeId="" InitialAsyncDataFetch="False" MissingAssembly="Cannot import this Web Part." HelpMode="Modeless" 
             ClientIDMode="g_8966a323_abbf_4513_83bb_1ce57b451422" ConnectionID="00000000-0000-0000-0000-000000000000" AllowZoneChange="True" 
            IsIncludedFilter="" __MarkupType="vsattributemarkup" __WebPartId="{8966A323-ABBF-4513-83BB-1CE57B451422}" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><ParameterBindings>
         <ParameterBinding Name="ListItemId" Location="QueryString(ID)" DefaultValue="0"/>
         <ParameterBinding Name="weburl" Location="None" DefaultValue="http://ctct-dev/sites/plm"/>
         <ParameterBinding Name="ListName" Location="None" DefaultValue="QueryString(ListId)" />
         <ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
         <ParameterBinding Name="ManualRefresh" Location="WPProperty[ManualRefresh]"/>
         <ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
         <ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
     </ParameterBindings>

Estas foram definidas usando o seguinte código para trás:

protected Guid listId;
protected string listName;

protected void Page_Load(object sender, EventArgs e)
{
    SPList list = SPContext.Current.Site.RootWeb.Lists[new Guid(Request.QueryString["List"])];
    listName = list.Title;
    listId = list.ID;
    DataBind();
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a sharepoint.stackexchange
scroll top