它确定这个问题的解决方案就是这篇文章所说的内容:http://codinglifestyle.wordpress.com/2009/10/08/repeaters-and-lost-data-after-postback-viewstate/然而它对我的接缝不起作用:|
所以我有一个页面,在那个页面中有一个有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>
在init上我调用这个方法
protected override void InitEditor()
{
if (!IsPostBack)
{
...
repFissaggio.DataSource = SolettoDS.SoleXSchTec;
repFissaggio.DataBind();
}
}
在这个中继器之上,我有其他网络控制。当我更改下拉列表的值时,表单将被提交。当发生这种情况时,来自转发器的webcontrol的值会失去它们的值。 你有什么建议的? 感谢。
答案 0 :(得分:0)
我找到了答案:我应该将绑定放在protected void repFissaggio_ItemDataBound(object sender,RepeaterItemEventArgs e)而不是repFissaggio_ItemCreated