Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2007, 09:56 PM
Authorized User
 
Join Date: Oct 2006
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Default Selecting Text When Editing Datagrid

Hi,

I have an application that uses a datagrid with EDIT column. The program runs fine and I am able to edit the column of datagrid using the code :

 Datagrid1.EditItemIndex = E.Item.ItemIndex

The code works fine, however, I believe it would be more user friendly if I can make the data of the column to be selected automatcially when EDIT button is clicked. Because what happens in the application is, when you click EDIT button, the data will be displayed for editing, and you will have to click again the mouse to the textbox to edit the data. I would want the focus to go to the textbox automatically so that user can immediately enter new data.

Thanks so much in advance!


 
Old May 29th, 2007, 04:58 PM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to zak_willis
Default

Hi there. I won't be posting my code as it is probably over-excessive, but I can tell you how to solve this. The basic problem is that the asp.net 1.1 datagrid doesn't really come up to scratch. Yes, sure you can click an edit column and make it appear as a text box column but what you really want is to be able to have textboxes, checkboxes and dropdowns, you need to be able to create dynamic template columns. I don't think many people would not want to have some form of dynamism as opposed to setting the templates up manually.
For this you need to implement the Itemplate interface and use the Instantiate in method. This allows you to add a textbox, combobox, etc at runtime and set the value to the value of the databinder. A handler is then created that adds the relevant control to the datagridcell. The end result is a datagrid of editable text boxes etc.


Zak Willis
Managing Director of www.blue-rhino.co.uk





Similar Threads
Thread Thread Starter Forum Replies Last Post
Editing Datagrid toddw607 ASP.NET 2.0 Basics 5 April 26th, 2007 03:06 PM
Editing in DataGrid abdul_owiusa ASP.NET 1.0 and 1.1 Professional 0 May 1st, 2006 07:56 AM
insert text into a text box by selecting an link gavmc Other Programming Languages 0 February 15th, 2006 09:46 AM
Editing a Text File mh VB.NET 1 December 8th, 2005 02:37 AM
Editing text in a richtextbox ja8261 VB.NET 2002/2003 Basics 5 March 9th, 2005 04:10 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.