Solved

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

Posted on 2007-04-04
2
324 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
Comment Utility
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
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

743 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now