繁体   English   中英

中继器控件中的Web控件失去了其价值

[英]Webcontrols from a repeater control loose their value

它似乎暗示了此问题的解决方案就是本文中所说的: http : //codinglifestyle.wordpress.com/2009/10/08/repeaters-and-lost-data-after-postback-viewstate/但是它接缝对我不起作用:|

所以我有一个页面,在该页面中有一个具有3个Web控件的转发器。

   <asp:Repeater ID="repFissaggio" runat="server" OnItemCreated="repFissaggio_ItemCreated" EnableViewState="true" >
    <ItemTemplate>
        <table width="100%">
            <tr>
                <td style="width:30%;border: gray 1px solid;">
                    <div style="text-align: center; width:100%; border-right: gray 1px solid; border-top: gray 1px solid; border-left: gray 1px solid;border-bottom: gray 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;    FONT-WEIGHT: bold; FONT-SIZE: 12px; background-color:gainsboro;">Disegno Articolo</div>
                    <asp:Image runat="server" ImageUrl='<%# GetFileAddress(Container.DataItem) %>' Width='220px' ID="imgDisegnoArt"  EnableViewState="false"></asp:Image>
                </td>
                <td style="width:65%">
                    <div style="text-align: center; width:100%; border-right: gray 1px solid; border-top: gray 1px solid; border-left: gray 1px solid;border-bottom: gray 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;    FONT-WEIGHT: bold; FONT-SIZE: 12px; background-color:gainsboro;">Informazioni Articolo</div>
                    <gsc:SchSolettoFinissaggioArticoloUC ID="ucSchSolettoFinissaggioArticolo" runat="server"></gsc:SchSolettoFinissaggioArticoloUC>
                </td>
            </tr>
            <tr>
                <td style="border: gray 1px solid;">
                    <div style="text-align: center; width:100%; border-right: gray 1px solid; border-top: gray 1px solid; border-left: gray 1px solid;border-bottom: gray 1px solid; FONT-FAMILY: Verdana, Arial, Helvetica, sans-serif;    FONT-WEIGHT: bold; FONT-SIZE: 12px; background-color:gainsboro;">Schema Finissaggio</div>
                    <asp:Image runat="server" ImageUrl='<%# GetFileAddress(Container.DataItem) %>' Width='220px' ID="imgSchedaFissaggio" EnableViewState="false"></asp:Image>
                    <asp:Label ID="divfileName" runat="server" Text='<%# GetFileName(Container.DataItem) %>' style="text-align: center; width:100%"></asp:Label>
                </td>
                <td>
                    <fieldset  style="padding: 10px,10px,10px,10px; border-bottom-width: 5px">
                        <legend>Sistema di Industrializzazione</legend>
                        <gsc:SchSolettoSistemaProdIndusUC ID="ucSchSolettoSistemaIndus" runat="server"></gsc:SchSolettoSistemaProdIndusUC>
                    </fieldset>
                    <br />
                    <fieldset  style="padding: 10px,10px,10px,10px; border-bottom-width: 5px">
                    <legend>Sistema di Produzione</legend>
                        <gsc:SchSolettoSistemaProdIndusUC ID="ucSchSolettoSistemaProd" runat="server"></gsc:SchSolettoSistemaProdIndusUC>
                    </fieldset>
                </td>
            </tr>
        </table>
    </ItemTemplate>
</asp:Repeater>

在初始化时,我调用此方法

 protected override void InitEditor()
        {
            if (!IsPostBack)
            {
                ...
                repFissaggio.DataSource = SolettoDS.SoleXSchTec;
                repFissaggio.DataBind();
            }

        }

在此转发器上方,我还有其他Web控件。 当我更改下拉列表的值时,将提交表单。 当发生这种情况时,来自中继器的webcontrol的值将失去其值。 您建议做什么? 谢谢。

我找到了答案:我应该将绑定放在受保护的void repFissaggio_ItemDataBound(object sender,RepeaterItemEventArgs e)中,而不要放在repFissaggio_ItemCreated中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM