TextBox 및 LinkButton이 포함 된 Repeater가 있습니다. 하는 LinkButton을 클릭하면, 나는 EVENT Repeater1_ItemDataBound (개체를 보낸 사람, RepeaterItemEventArgs 전자) 나는 전자 = 텍사스 텍스트 상자를 사용하여 텍스트 상자의 값을 얻을 수 있어요 사용 ...이벤트 처리기 TextBox 컨트롤이있는 OnItemCommand
TextBox.Text를 잡고 물건을 할 필요가 내가 다시 아무것도 못하고 오전 EVENT Repeater1_ItemCommand (개체를 보낸 사람, RepeaterCommandEventArgs 전자)를 사용하여 텍스트 상자
그러나
로 .Item.FindControl ("txCode"). TextBox가 비어 있습니다.
어떻게 'OnItemCommand'를 사용하여 TextBox에서 텍스트/콘텐츠를 가져올 수 있습니까? 내가
protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
TextBox tx = e.Item.FindControl("txCode") as TextBox;
string myText = tx.Text; '<--- working
}
아래의 텍스트 상자의 값을 얻을 수 있어요
<asp:Repeater ID="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound" OnItemCommand="Repeater1_ItemCommand">
<ItemTemplate>
<li>
<asp:TextBox ID="txCode" runat="server"></asp:TextBox>
<asp:LinkButton CommandName="verifyCode" ID="lbCode" runat="server">Submit<asp:LinkButton>
</li>
</ItemTemplate>
</asp:Repeater>
내가하는 Repeater
를 결합하지 마십시오
protected void Repeater1_ItemCommand(object sender, RepeaterCommandEventArgs e)
{
if (e.CommandName == "verifyCode")
{
TextBox tx = e.Item.FindControl("txCode") as TextBox;
string myText = tx.Text; '<--- NOT working
}
는이 이벤트가 발생합니다 있는지 확인하기 위해 디버깅이 있나요? 아마 당신은 Page_Load에서'! IsPostBack'을 체크하지 않았을 것입니다. 포스트 백에없는 repeater를 DataSource에 바인딩하십시오. –
if (! IsPostBack) - Damm <- worked! 감사합니다 @ 팀 Schmelter –