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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Datagrid with Edit, Update, Cancel (Update Not working) 1

Status
Not open for further replies.

frmorris

Programmer
Aug 4, 2005
22
0
0
US
I have a datagrid with an Edit, Update, and Cancel command. The Edit and Cancel commands are working. However, when I click the update link nothing happens. I want the updated information to change and update in the sql database. Can someone please help me?

Sub masterDataGrid_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)

Dim txtUsername As TextBox = e.Item.Cells(2).Controls(0)
Dim txtEvent As TextBox = e.Item.Cells(3).Controls(0)

Dim eventid As Integer = e.Item.Cells(1).Text
Dim EventView As DataView
Dim dtEvent As DataTable

EventView.RowFilter = "Item='" & eventid & "'"
If EventView.Count > 0 Then
EventView.Delete(0)
End If
EventView.RowFilter = ""

Dim dr As DataRow = dtEvent.NewRow()
dr(0) = username
dr(1) = eventid
dr(2) = events
dtEvent.Rows.Add(dr)

masterDataGrid.EditItemIndex = -1
masterDataGrid.DataSource = EventView
masterDataGrid.DataBind()
BindGrid()

End Sub
 
You need the Handles statement, which is either .UpdateCommand or .Update (I forget which one)
Code:
Sub masterDataGrid_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) [b]Handles masterDataGrid.UpdateCommand[/bb]
 
Hi Mike,
I tried the handles solution, but it did not work. It redirect me back to my user log-in request form.
 
Thanks dvannoy. Your link was a great resource.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top