Text property ItemTemplate

2 posts, 0 answers
  1. Deivison Julio
    Deivison Julio avatar
    3 posts
    Member since:
    Feb 2012

    Posted 16 Apr 2012 Link to this post

    How do I get the text of a textbox within an ItemTemplate(ListBox) to submit a form?

    I am using the code below. The control is found but the Text property is always empty ("") 

    protected void ListBoxFeeds_ItemDataBound(object sender, RadListBoxItemEventArgs e)
    {
            btnComment = e.Item.FindControl("PostComment") as RadButton;
     
            CommentContent = ((RadTextBox)e.Item.FindControl("InputComment")).Text;
     
            btnComment.Click += new EventHandler(btnComment_Click);
      
    }

  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Apr 2012 Link to this post

    Hello Deivison,

    Here is the sample code that I tried which worked as expected.
    C#:
    protected void RadListBox1_ItemDataBound(object sender, RadListBoxItemEventArgs e)
    {
     RadListBoxItem item = (RadListBoxItem)e.Item;
     RadTextBox txt = (RadTextBox)item.FindControl("InputComment");
     string value = txt.Text;
    }

    Thanks,
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top