|
-
Sep 18th, 2005, 11:52 PM
#1
Thread Starter
Fanatic Member
Need help with datagrid and dataset in ASP.NET
I got it down how to fill a datagrid with a dataset. The difficulty is when I try to rewrite back to the database with the SQLDataAdapter. The page refreshes on the 'Update' button click so the DataSet is empty. How to I slurp the data off of the Datagrid back into the DataSet?
Here's some of my pseudo-code:
-------------------------------------
The fill grid part works:
Private Sub btnFillGrid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFillGrid.Click
Dim sqlcomm As New SqlCommand("SELECT * from WebUsers")
sqlcomm.Connection = cn
Dim sqlda As New SqlDataAdapter
sqlda.SelectCommand = sqlcomm
cn.Open()
sqlda.Fill(ds)
cn.Close()
dgUsers.DataSource = ds
dgUsers.DataBind()
----------------------------------------------------------------
Private Sub btnGridUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGridUpdate.Click
' The Update command is declared elsewhere and it works
' the ds is declared as a dataset class variable
' need code to fill modified dataset with changes so this update will work
Dim sqlda As New SqlDataAdapter
Dim sqlupd As SQLCommand = SQLUpdateCommand1
sqlda.UpdateCommand = sqlupd
sqlupd.Connection = cn
cn.Open()
sqlda.Update(ds)
cn.Close()
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|