Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Datagrid - Edit/Update Question

Reply
Thread Tools

Datagrid - Edit/Update Question

 
 
Jennifer
Guest
Posts: n/a
 
      07-13-2006
I've got a datagrid. I want to allow the user to edit in the grid
directly. I'm using ASP with VB as the code behind in Visual Studio
2002.

I've never had a need or desire to do this before, so I found an
Quickstart example at DotNetJunkies.com. I've modified it for my needs
and can't get it to work. Specifically, the part where I get the
edited cell values does not work. e.Item.Cells(1).Text returns
nothing. None of the other indexes returns anything either. Please
help me out.

Truly appreciated,
Jennifer

Private Sub dgNotes_UpdateCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
dgNotes.UpdateCommand
Dim sPicked As String
Dim i As Integer
Dim FName As String
Dim LName As String
Dim N As String
Dim sUpdateQuery As String
Dim con As New ConnectDB()
Dim cn As SqlClient.SqlConnection
Dim cmd As SqlClient.SqlCommand
Dim RetVal As Int16
Dim sFeedback As String = e.Item.Cells(1).Text
Dim sProject As String = e.Item.Cells(2).Text
Dim sShift As Integer = e.Item.Cells(3).Text
Dim sDate As String = e.Item.Cells(4).Text
Dim sNote As String = e.Item.Cells(5).Text

sPicked = Request("N")
i = InStr(sPicked, ",")
FName = Trim(Mid(sPicked, i + 1))
LName = Trim(Left(sPicked, i - 1))
N = Me.User.Identity.Name.ToString

sUpdateQuery = "UPDATE Captured_Data " & _
"Set Feedback = '" & sFeedback & "', Project = '" & sProject &
"', Shift = " & _
sShift & ", [Date] = '" & Date.Now & "',Information = '" &
sNote & "', " & _
"Agent_FirstName = '" & FName & "', Agent_LastName = '" & LName
& "', Note_Author = '" & _
N & "' Where Agent_LastName = '" & LName & "' and
Agent_FirstName = '" & FName & "' and " & _
"[Date] = '" & sDate & "'"

txtNotes.Text = sUpdateQuery

cn = con.ConnectDB
cn.Open()
cmd = New SqlClient.SqlCommand(sUpdateQuery, cn)
cmd.CommandType = CommandType.Text
RetVal = cmd.ExecuteNonQuery()
cn.Close()
FillGrid()
txtFeedback.Text = ""
txtProject.Text = ""
txtShift.Text = ""
txtNotes.Text = ""
lblErr.Visible = False

End Sub

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Datagrid: how cut short display of a long description in a datagrid column Brian K. Williams ASP .Net 0 03-02-2004 08:35 PM
RE: Datagrid: how cut short display of a long description in a datagrid column =?Utf-8?B?U3VyZXNo?= ASP .Net 0 03-02-2004 08:31 PM
datagrid in datagrid BK Kim ASP .Net 1 03-02-2004 06:34 AM
Call Datagrid Command column outside datagrid Dave ASP .Net 0 11-20-2003 11:11 AM
To all Gurus: How can I edit/update a DataGrid in a DataGrid (nested DataGrid)? Possible? Andreas Klemt ASP .Net Datagrid Control 0 10-08-2003 01:19 AM



Advertisments