N
Nishen Naidoo
Hi,
I have this datagrid on a page with two columns viz ID and Category. I want
users to be able to edit the category data.
This is what I got. When I uncomment the postback below, the grid
dissappears when I click the edit link. As it stands, the Update event is
not triggered. When I click the edit link, a text box appears in the
category column for that row. I then change it and click update. I then
want to see the new data in my test label (txt.text = newData).
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Category_SqlDataAdapter.Fill(Category_Dataset)
'If Not IsPostBack Then
' Category_Datagrid.DataBind()
'End If
Category_Datagrid.DataBind()
End Sub
Private Sub Category_Datagrid_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
Category_Datagrid.EditCommand
Category_Datagrid.EditItemIndex = e.Item.ItemIndex
Category_Datagrid.DataBind()
txt.Text = e.Item.ItemIndex
End Sub
Private Sub Category_Datagrid_UpdateCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
Category_Datagrid.UpdateCommand
Dim newData As String
Dim aTextBox As TextBox
aTextBox = CType(e.Item.Cells(1).Controls(0), TextBox)
newData = aTextBox.Text
txt.Text = newData
End Sub
Am i missing something?
thanx
Nish
I have this datagrid on a page with two columns viz ID and Category. I want
users to be able to edit the category data.
This is what I got. When I uncomment the postback below, the grid
dissappears when I click the edit link. As it stands, the Update event is
not triggered. When I click the edit link, a text box appears in the
category column for that row. I then change it and click update. I then
want to see the new data in my test label (txt.text = newData).
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Category_SqlDataAdapter.Fill(Category_Dataset)
'If Not IsPostBack Then
' Category_Datagrid.DataBind()
'End If
Category_Datagrid.DataBind()
End Sub
Private Sub Category_Datagrid_EditCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
Category_Datagrid.EditCommand
Category_Datagrid.EditItemIndex = e.Item.ItemIndex
Category_Datagrid.DataBind()
txt.Text = e.Item.ItemIndex
End Sub
Private Sub Category_Datagrid_UpdateCommand(ByVal source As Object, ByVal e
As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
Category_Datagrid.UpdateCommand
Dim newData As String
Dim aTextBox As TextBox
aTextBox = CType(e.Item.Cells(1).Controls(0), TextBox)
newData = aTextBox.Text
txt.Text = newData
End Sub
Am i missing something?
thanx
Nish