D
dew
I have a grid, when the user clicks on an add link (code below), enters values, then clicks Update
Public Sub AddRecord(ByVal dgrid)
Dim ds As DataSet
Dim dt As DataTable
Dim dr As DataRow
ds = Session("DS")
'Copy the structure of the dataset, no data, and add a blank row for data entry
dt = ds.Tables(0).Clone
dr = dt.NewRow()
dt.Rows.Add(dr)
'Hide the checkmark column; display the edit/update/cancel column
dg.Columns(0).Visible = False
dg.Columns(1).Visible = True
With dgrid
.EditItemIndex = 0
.DataSource = dt
.DataBind()
End With
When the user clicks on Update, I have tried the following and there are no values; I got this from Microsofts Code: Getting Cell Values in the Datagrid Web Server Control. I know the event fires because I can step through it. My datagrid is autogenerated, and this is the only difference from grids that do work. Is that the problem? Can we not get values from a grid when using autogenerated columns??
Thanks for you rhelp.
Private Sub dg_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid.UpdateCommand
Dim i As Integer
Dim s As String
For i = 0 To dg.Columns.count - 1
s &= "<BR>" & e.Item.Cells(i).Text.ToString
Next
Response.Write(s)
End Sub
Public Sub AddRecord(ByVal dgrid)
Dim ds As DataSet
Dim dt As DataTable
Dim dr As DataRow
ds = Session("DS")
'Copy the structure of the dataset, no data, and add a blank row for data entry
dt = ds.Tables(0).Clone
dr = dt.NewRow()
dt.Rows.Add(dr)
'Hide the checkmark column; display the edit/update/cancel column
dg.Columns(0).Visible = False
dg.Columns(1).Visible = True
With dgrid
.EditItemIndex = 0
.DataSource = dt
.DataBind()
End With
When the user clicks on Update, I have tried the following and there are no values; I got this from Microsofts Code: Getting Cell Values in the Datagrid Web Server Control. I know the event fires because I can step through it. My datagrid is autogenerated, and this is the only difference from grids that do work. Is that the problem? Can we not get values from a grid when using autogenerated columns??
Thanks for you rhelp.
Private Sub dg_UpdateCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid.UpdateCommand
Dim i As Integer
Dim s As String
For i = 0 To dg.Columns.count - 1
s &= "<BR>" & e.Item.Cells(i).Text.ToString
Next
Response.Write(s)
End Sub