473,385 Members | 1,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Datagrid - Edit/Update Question

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

Jul 13 '06 #1
0 926

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jim Heavey | last post by:
Trying to figure out the technique which should be used to add rows to a datagrid. I am thinking that I would want an "Add" button on the footer, but I am not quite sure how to do that. Is that...
2
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last,...
1
by: Rick | last post by:
Hello all, I hope all is well with you. I am having a seriously difficult time with this problem. Allow me to set up the problem. I have a System.Web.UI.Page with the following controls...
0
by: Steve | last post by:
I have a datagrid that is created at run time DataGrid dgG = new DataGrid(); BoundColumn bcB; dgG.CellPadding = 5; dgG.CellSpacing = 0; dgG.GridLines = GridLines.Both; dgG.CssClass =...
9
by: tshad | last post by:
Is there a way to use your own image in place of the automatic one that ASP uses when doing editing in your DataGrid pages? We already have a style of button we are using and would like to be...
5
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
3
by: CharlesA | last post by:
Hi folks, I really need help with the following scenario, I'm going to describe as well as a I can what the setup is and what I can't understand I'm using the framework 1.1 using ASP.net with...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
0
by: arlie_maija | last post by:
Hey - I'm writing a control that contains a DataGrid, and I'm unable to get the update event to fire. When I click the update link, the edit event fires. heres the details... my control...
2
by: Iain | last post by:
Hi All Using Delphi 2006 developer - C# Project I have the following 2 event handlers for the datagrid - see botton of page Both events will fire off correctly but i have a problem collecting...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.