Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating from datagrid :s 1

Status
Not open for further replies.

N3XuS

Programmer
Mar 1, 2002
339
BE
I'm using the following event handler ... which is triggered.
Code:
    Private Sub DataGrid1_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.UpdateCommand
        Dim txtTb As TextBox
        txtTb = CType(e.Item.Cells(3).Controls(0), TextBox)
        Me.txtFeed.Text = txtTb.Text
        strCulture = "nl-BE"
        Dim spId As SqlParameter
        Dim spPaystate As SqlParameter
        spId = New SqlParameter("@Id", e.Item.Cells(0).Text)
        spPaystate = New SqlParameter("@Paystate", e.Item.Cells(3).Text)
        Dim spaSqlParameters() As SqlParameter = {spId, spPaystate}
        Database.EditObject("UpdPaystate", spaSqlParameters)
        DataGrid1.EditItemIndex = -1
        Me.FillDatagrid()
    End Sub

Problem is e.Item.Cells(3).Text is getting the original value and not the value I changed it to :s any ideas why ?

Many thx.
 
Yes, it will get the original value until you save the changes to the DB and rebind the grid.

Jim
 
So euh where do I get the changes ? The changes are reflected in the DataTable straight away ?
 
If you are using a dataset or datatable you need to update the values there first. Then you can grab the updated value before you rebind the grid.
 
But I don't know where to get the change ... the textbox itself gives me the original value so where else can I get the newly entered value ?
 
After you save it to the datatable, you can go to that row, that column and grab the value. You can also do the same thing from the datagrid after you re-bind it.
 
lol how do I save the datagrid back to the datatable -> mega noob in this stuff :s
 
Hope that does the trick , thanks a lot man :)
 
no prolbem..good luck :) that is a great example and should help you.

Jim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top