Question

It seams that the solution for this problem would be what it is said in this post: http://codinglifestyle.wordpress.com/2009/10/08/repeaters-and-lost-data-after-postback-viewstate/ however it seams that for me does not work :|

So I have a page and in that page a repeater that has 3 webcontrols.

   <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>

On init I call this method

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

        }

Above this repeater I have other webcontrols. When I change a value of a dropdown the form is submitted. When that happens values of webcontrol from repeater looses their value. What do you suggest to do? Thanks.

Was it helpful?

Solution

I found the answer: I should put binding in protected void repFissaggio_ItemDataBound(object sender, RepeaterItemEventArgs e) and not in repFissaggio_ItemCreated

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top