Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Urgent!Pls help me with getting data from the textbox template field in the grid

Can anyone help me with getting data from the textbox template field in the gridview?

Here is my code for the textbox template field in the gridview.

<Columns>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:textbox runat="server" ID="QuantityTxtBox" />
</ItemTemplate>
</asp:TemplateField>
</Columns>

After entering data into the textbox in the gridview, I try to get the data in the first row and display it into LABEL1 with the following code

Dim text As String
Dim tb As TextBox = CType(LecReqGV.Rows(0).FindControl("QuantityTextbox"), TextBox)

If Not (tb.Text.Equals("")) Then
text = tb.Text
Label1.Text = text
End If


The code doesnt work and the error message Object reference not set to an instance of an object. keeps prompting out. Can anyone help me with that?
[1012 byte] By [seanlaw] at [2007-11-11 10:28:59]
# 1 Re: Urgent!Pls help me with getting data from the textbox template field in the grid
probably because

QuantityTxtBox is spelt differently to QuantityTextbox
CapilanoSpur at 2007-11-11 23:11:52 >