Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2007-04-04
2
Medium Priority
?
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
sandip132 earned 1500 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

Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

688 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