Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Collecting values from gridview

Status
Not open for further replies.

fawkes

Technical User
Sep 12, 2003
343
GB
I have a gridview with a textbox that users can enter information into

Code:
<asp:TemplateField HeaderText="Filter Text">
                        <ItemTemplate>
                            <asp:TextBox ID="CriteriaTextBox" runat="server" EnableViewState="true"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>

But I can't seem to access the information entered

Code:
Dim gridText As TextBox
        gridText = CType(GridView1.Rows(0).FindControl("CriteriaTextBox"), TextBox)

gridText always returns as Nothing, can anyone shed some light on this, I'm probably doing something very basic that is wrong.
 
At what point are you trying to get the value? In what event are you running the code you posted?
 
This has worked for me:

gridText = CType(GridView1.Rows(0).Cell(0).FindControl("CriteriaTextBox"), TextBox).Text

SMBrown



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top