Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 13th, 2003, 05:42 PM
rlangham rlangham is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 3 rlangham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Updating DataSet from an edited DataGrid

I have a DataGrid that allows editing of records. I have taken over the OnUpdateCommand event and I wish to move the edited values back into the proper DataRow of a persisted dataset. Basically, I want to let the user modify one or more rows and then update them all in a single batch operating using the DataAdapter.Update( dataset ) command.<br><br>All the examples that I have seen to update a DataSet from the DataGrid use code like below. Basically, it has hardwired code grabbing the values from the grid Cell Controls into known hardwired variables. I was hoping to make something a little more generic so it could handle almost any DataGrid and any DataSet using the bounded column caption and the DataSet column caption. For example, I would think that I should be able to loop through the columns of the datagrid, find the Bounded Column object, get its DataField value, get the edited text value, find the associated column/row in the dataset and update it. But, can't find a way of doing this, any suggestions...<br><br>Sub MyDataGrid_UpdateCommand(s As Object, e As DataGridCommandEventArgs )<br> Dim conn As SqlConnection<br> Dim MyCommand As SqlCommand<br> Dim strConn as string = "server=YourServer;uid=UID;pwd=PWD;database=Northwi nd"<br><br> ' Hardwired knowledge of the datagrid columns (not generic!)<br> Dim txtFirstName As textbox = E.Item.cells(2).Controls(0)<br> Dim txtLastName As textbox = E.Item.cells(3).Controls(0)<br> Dim txtTitle As textbox = E.Item.cells(4).Controls(0)<br><br> ' Code here to either update the DataSet directly or call SQL update command<br> ' code removed for this example....<br><br> MyDataGrid.EditItemIndex = -1<br> BindData<br>End Sub<br><br>Thanks for any help,<br>Ron

Reply With Quote
  #2  
Old February 13th, 2003, 11:07 PM
Andrew Andrew is offline
dotNetBB Forums Developer
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Posts: 265 Andrew User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Andrew Send a message via AIM to Andrew Send a message via Yahoo to Andrew
Lots of good datagrid articles can be found at <a href="http://www.datagridgirl.com/articles.aspx" target="_blank">www.datagridgirl.com/articles.aspx</a><p> </p><p><hr size="1" width="50%" align="left" />dotNetBB Forum Developer<br><b><i>Building A Better Community, One Post At A Time</i></b><br><a href="http://www.dotnetbb.com" target="_blank">www.dotnetbb.com</a></p>

Reply With Quote
  #3  
Old February 13th, 2003, 11:21 PM
rlangham rlangham is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Posts: 3 rlangham User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes, I found datagridgirl in my searches before posting. Pretty nice site, but did not appear to have an answer to my question. <br><br>Possibly I could get around this problem if I knew of a way to get the bounded column information from the DataGrid.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Updating DataSet from an edited DataGrid


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT