When I click edit, the info in the cells disappear and the textboxes are blank???
Private Sub Page_Load...
If Not Page.IsPostBack Then
SqlConnection1.Open()
SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM info"
SqlDataAdapter1.Fill(DS, "info")
DataGrid1.DataSource = DS.Tables(0)
DataGrid1.DataBind()
SqlConnection1.Close()
End If
End Sub
Sub DataGrid1_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
DataGrid1.EditItemIndex = e.Item.ItemIndex
End Sub
Thanks loads I know I'm missing something simple...Since the editing row did not exist before, it's empty. To fill it you need to rebind your data by opening the SQL connection, populating the data set etc, just like you did in Page_Load. (You might want to put all of this code into a separate Sub.)
Private Sub Page_Load...
If Not Page.IsPostBack Then
SqlConnection1.Open()
SqlDataAdapter1.SelectCommand.CommandText = "SELECT * FROM info"
SqlDataAdapter1.Fill(DS, "info")
DataGrid1.DataSource = DS.Tables(0)
DataGrid1.DataBind()
SqlConnection1.Close()
End If
End Sub
Sub DataGrid1_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)
DataGrid1.EditItemIndex = e.Item.ItemIndex
End Sub
Thanks loads I know I'm missing something simple...Since the editing row did not exist before, it's empty. To fill it you need to rebind your data by opening the SQL connection, populating the data set etc, just like you did in Page_Load. (You might want to put all of this code into a separate Sub.)