Get textbox value from datagrid problem

S

Steve F.

Hi, could you please tell me what is wrong with this piece of code.
I have a DataGrid, and I would like to know the value of a textbox field,
and it never returns anything.
textbox is in item template.

<asp:TemplateColumn HeaderText="Value">
<ItemTemplate>
<asp:TextBox id="txtInput" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateColumn>

Dim item As DataGridItem
If Not IsPostBack Then

For Each item In DataGrid1.Items
Dim tb As TextBox = CType(item.FindControl("txtInput"),
TextBox)
ListBox1.Items.Add(tb.Text)
Next
End If


Thank you.
Steve
 
M

Michael Tkachev

Hi,

the following code has been create in the C#. You will be able to translate
to the VB.Net

C#
TextBox txt = ((TextBox)item.Columns[0].Controls[0]);

VB:
Dim tb As TextBox = CType(item.Columns(0).Controls(1))

Right now you know how you can get a value from a textbox.

bye
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,710
Latest member
bernietqt

Latest Threads

Top