Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > ADO.NET
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 5th, 2004, 12:12 AM
Registered User
 
Join Date: Mar 2004
Location: , , New Zealand.
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
Reply With Quote
  #2 (permalink)  
Old March 16th, 2004, 02:58 PM
Authorized User
 
Join Date: Jun 2003
Location: Crowland, Lincs, United Kingdom.
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 09:21 AM.


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