This is a migrated thread and some comments may be shown as answers.

Text property ItemTemplate

1 Answer 82 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Deivison Julio
Top achievements
Rank 1
Deivison Julio asked on 16 Apr 2012, 06:13 PM
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);
  
}

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 17 Apr 2012, 05:25 AM
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.
Tags
ListBox
Asked by
Deivison Julio
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or