Solved

Find Controls in <EditItemTemplate> in GridView web control, ASP.NET 2.0

Posted on 2007-04-04
2
331 Views
Last Modified: 2013-11-26
Hi experts,

I'm have GridView control in my ASP.NET page. Within  <EditItemTemplate> in one of the GridView's columns, there is a Textbox. I'm just wondering, is it possible / how to get a reference of the textbox control so I can do something with it (i.e. When user enter editing mode, set the width of the textbox base on the length of text string)

 I tried the following, but it gives me NullReference exception

Private Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
        Dim mytxt As TextBox = Me.GridView1.Rows(e.NewEditIndex).FindControl("txtLastName")
        mytxt.Columns = GridView1.Rows(e.NewEditIndex).Cells(3).Controls.Item(1)      ' This is the text supposed to be  in the textbox
End Sub
0
Comment
Question by:caibeier
2 Comments
 
LVL 12

Accepted Solution

by:
sandip132 earned 500 total points
ID: 18855599
This will help you out
http://www.codeproject.com/useritems/EditGridviewCells.asp

but I am not sure about setting the width of textbox on the fly.
0
 

Author Comment

by:caibeier
ID: 18930475
Thanks for the info sandip132, I found out that the reason I got NULL Reference is because I disabled the viewstate of the gridview control
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question