0

似乎这个问题的解决方案就是这篇文章中所说的: 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 的值就会失去它们的价值。你建议怎么做?谢谢。

4

1 回答 1

0

我找到了答案:我应该将绑定放在 protected void repFissaggio_ItemDataBound(object sender, RepeaterItemEventArgs e) 而不是 repFissaggio_ItemCreated

于 2013-01-04T07:23:16.990 回答