我从嵌套中继器内的文本框中获取新值时遇到问题。如果我像这样在 Text 属性中键入静态值:我可以获取该值,但不能获取新值。
<ItemTemplate>
<tr>
<td width="160">
<%# Eval("index")%>
</td>
<td>
<%# Eval("Sex") %>
</td>
<td align="right">
<button id="EditPuppy" class="open-dialog" runat="server">
Rediger hvalp</button>
<juice:Button TargetControlID="EditPuppy" runat="server" />
</td>
<td align="right" width="30">
<asp:ImageButton runat="server" ID="DeletePuppy" CommandArgument='<%# Eval("dogid").ToString() %>'
OnClientClick='return confirm("Er du sikker på at du gerne vil slette denne hvalp?")'
OnCommand="DeletePuppy_Command" SkinID="DefaultDeleteButton" />
</td>
</tr>
<div id="_Default" runat="server" class="basic-dialog" title="Basic dialog" runat="server">
<asp:TextBox runat="server" ID="TextBoxPuppyName" Text="HEJ" /><!-- The textbox i am trying to get the value from -->
<asp:Button UseSubmitBehavior="false" runat="server" ID="ButtonPuppyName" CommandArgument="<%# ((RepeaterItem)Container.Parent.Parent).ItemIndex %> <-- Getting parent repaterid"
CommandName="<%# Container.ItemIndex %> <-- Getting current repeater index -->"
OnCommand="ButtonPuppyName_Command" Text="Opdater" />
</div>
<juice:Dialog TargetControlID="_Default" AutoOpen="false" runat="server" />
</ItemTemplate>
代码隐藏:
protected void ButtonPuppyName_Command(object sender, CommandEventArgs e) {
int parentRepeaterItemIndex = Convert.ToInt32(e.CommandArgument);
int childRepeaterItemIndex = Convert.ToInt32(e.CommandName);
Repeater childReapter = (Repeater)RepeaterShowKuldUserList.Items[parentRepeaterItemIndex].FindControl("RepeaterShowKuldPuppyList");
TextBox name = (TextBox)childReapter.Items[childRepeaterItemIndex].FindControl("TextBoxPuppyName");
HttpContext.Current.Response.Write(name.Text);
}
谢谢你的帮助!。记住进入中继器工作,因为我可以获得“静态”值