Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
|
ADO.NET For discussion about ADO.NET.  Topics such as question regarding the System.Data namespace are appropriate.  Questions specific to a particular application should be posted in a forum specific to the application .
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ADO.NET 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 March 5th, 2004, 12:12 AM
Registered User
 
Join Date: Mar 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default Newbie - Editing a datagrids row on a new page

Hi,

I have a datagrid on my main page containing job records.
When the user wants to edit one of these I want to direct them
to a new page displaying the record in a series of text boxes and other controls etc.
What is the best way to do this?
The way I have done this in the past is by passing the record ID to the new page, creating a new recordset and binding the controls to the recordset. When the user saves the changes it writes the changes to the database and refreshes the grid on the main page.
However I don't feel that this is the best way to do this.

Any feedback would be great. (examples would be even better)

Regards,
Phil
 
Old March 16th, 2004, 02:58 PM
Authorized User
 
Join Date: Jun 2003
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I presumed you are working on with ASP.Net, since you are talking about Main Page and Next page.

In HTML code, at your data grid declartion, you can set your asp:ButtonColumn to be the DataTextField type, so user can able to select any job reference numbers. The you need to use CommandName, ie CommandName="JobSelected"

On your coding use the event ItemCommand on your datagrid. The object, e will generated auatomatically as one of the event's passing parameter, that will contains name of your datagrid event.
so, using a string var to catch event name,
string cmd=e.CommandName; (C#)
dim cmd as string = e.CommandName (VB.Net)
1. One you know the command name use switch (C#) or Case Select (VB.Net) to get your command to activate next.

2. You need to capture the row that your user had clicked. If you used a datatable to bind your datagrid, the row index of datagrid must be the same as your table. Using e.Item.DataSetIndex to find the row index. Once the row index found, you can access the rest of your data in the table which refered to user selected row on the datagrid.
3. Once you capture ref number, you can get all the rest of your data and pass it to the next page.

Hope I made myself clear, I am not a ASP pro just a novice. I had done similar thing to your problem, hope it helps






Similar Threads
Thread Thread Starter Forum Replies Last Post
Data Binding - Editing GridView Row Data desk_star BOOK: Professional ASP.NET 2.0 and Special Edition; ISBN: 978-0-7645-7610-2; ISBN: 978-0-470-04178-9 7 December 30th, 2007 11:07 AM
grid view row editing event fired after postback sasidhar79 ASP.NET 2.0 Professional 0 January 30th, 2007 08:17 PM
paging to the page of selected item or row ysiline ASP.NET 1.0 and 1.1 Professional 1 July 13th, 2006 05:20 AM
Newbie Help. Login to unique login page per user Kainan Classic ASP Professional 10 May 3rd, 2005 07:47 AM
datagrids question -- finding a specific row bazookajoe76 C# 1 January 22nd, 2005 12:08 PM





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