Solved

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

Posted on 2007-04-04
2
338 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 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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