I have an editable datagrid. Updating works fine, but I'm having trouble
with adding a new row: the datagrid does not go to update mode. So, the
new row is added to the datagrid, but you can't enter any data.
Below is my code.
Thanks in advance,
Sam Schotte
Belgium.
Public Sub AddNewRow(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim row As DataRow
Dim dt As New DataTable()
Dim nNewItemIndex As Integer
Dim ds As New DataSet()
ds = Session("myData")
dt = ds.Tables("MyTable")
row = dt.NewRow()
dt.Rows.Add(row)
Session("myData") = ds
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'Here is the problem: row is added, but datagrid
'does not go to edit mode
'!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
nNewItemIndex = grid.Items.Count + 1
grid.EditItemIndex = nNewItemIndex
UpdateView()
End Sub
Private Sub UpdateView()
Dim ds As New DataSet()
ds = Session("MyData")
grid.DataSource = ds.Tables("MyTable")
grid.DataBind()
End Sub