473,320 Members | 2,162 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,320 software developers and data experts.

Update Not Working for asp:DataGrid (VB2003 Standard)

Hi, i am trying to make a fully editable dataGrid and was using the
"Top Ten Questions about the DataGrid Control" article in the MSDN
Library as a guide. The following is my current vb code. I ran the
page, and only the first row updates. Can anyone help with this
problem? Thanks, TS
Public Sub dgUpdate(ByVal s As Object, ByVal e As EventArgs)
Dim i As Integer
Dim dgi As DataGridItem
Dim lblSID As Label
Dim txtC1 As TextBox
Dim txtC2 As TextBox
Dim txtC3 As TextBox
Dim txtC4 As TextBox
Dim txtE1 As TextBox
Dim txtS1 As TextBox
Dim intSID As String 'StudentID
Dim cmdUp As OleDbCommand
Dim strUp
strUp = "Update StudentData Set C1=@C1, C2=@C2, C3=@C3, C4=@C4,

E1=@E1, S1=@S1 Where StudentID=@SID and TchID=@TchID And
CourseID=@CourseID"
cmdUp = New OleDbCommand(strUp, conPI)
Dim totCount As Integer
totCount = dgrdStudents.Items.Count
For i = 0 To totCount - 1
dgi = dgrdStudents.Items(i)
lblSID = CType(dgi.FindControl("lblSID"*), Label)
intSID = CType(lblSID.Text, String)
txtC1 = CType(dgi.FindControl("txtC1")*, TextBox)
txtC2 = CType(dgi.FindControl("txtC2")*, TextBox)
txtC3 = CType(dgi.FindControl("txtC3")*, TextBox)
txtC4 = CType(dgi.FindControl("txtC4")*, TextBox)
txtE1 = CType(dgi.FindControl("txtE1")*, TextBox)
txtS1 = CType(dgi.FindControl("txtS1")*, TextBox)
cmdUp.Parameters.Add("@C1", txtC1.Text)
cmdUp.Parameters.Add("@C2", txtC2.Text)
cmdUp.Parameters.Add("@C3", txtC3.Text)
cmdUp.Parameters.Add("@C4", txtC4.Text)
cmdUp.Parameters.Add("@E1", txtE1.Text)
cmdUp.Parameters.Add("@S1", txtS1.Text)
cmdUp.Parameters.Add("@SID", lblSID.Text)
cmdUp.Parameters.Add("@TchID", varTID)
cmdUp.Parameters.Add("@CourseI*D",
Request.QueryString("CourseID"*))
conPI.Open()
cmdUp.ExecuteNonQuery()
conPI.Close()
Next
BindDataGrid()
End Sub

Nov 19 '05 #1
1 1208
One suggestion I would make is to create your parameters outside of the For
loop. I would then set the Value property of parameter inside the loop.

--
David Lloyd
MCSD .NET
http://LemingtonConsulting.com

This response is supplied "as is" without any representations or warranties.
"Schultz" <sc***********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi, i am trying to make a fully editable dataGrid and was using the
"Top Ten Questions about the DataGrid Control" article in the MSDN
Library as a guide. The following is my current vb code. I ran the
page, and only the first row updates. Can anyone help with this
problem? Thanks, TS
Public Sub dgUpdate(ByVal s As Object, ByVal e As EventArgs)
Dim i As Integer
Dim dgi As DataGridItem
Dim lblSID As Label
Dim txtC1 As TextBox
Dim txtC2 As TextBox
Dim txtC3 As TextBox
Dim txtC4 As TextBox
Dim txtE1 As TextBox
Dim txtS1 As TextBox
Dim intSID As String 'StudentID
Dim cmdUp As OleDbCommand
Dim strUp
strUp = "Update StudentData Set C1=@C1, C2=@C2, C3=@C3, C4=@C4,

E1=@E1, S1=@S1 Where StudentID=@SID and TchID=@TchID And
CourseID=@CourseID"
cmdUp = New OleDbCommand(strUp, conPI)
Dim totCount As Integer
totCount = dgrdStudents.Items.Count
For i = 0 To totCount - 1
dgi = dgrdStudents.Items(i)
lblSID = CType(dgi.FindControl("lblSID"*), Label)
intSID = CType(lblSID.Text, String)
txtC1 = CType(dgi.FindControl("txtC1")*, TextBox)
txtC2 = CType(dgi.FindControl("txtC2")*, TextBox)
txtC3 = CType(dgi.FindControl("txtC3")*, TextBox)
txtC4 = CType(dgi.FindControl("txtC4")*, TextBox)
txtE1 = CType(dgi.FindControl("txtE1")*, TextBox)
txtS1 = CType(dgi.FindControl("txtS1")*, TextBox)
cmdUp.Parameters.Add("@C1", txtC1.Text)
cmdUp.Parameters.Add("@C2", txtC2.Text)
cmdUp.Parameters.Add("@C3", txtC3.Text)
cmdUp.Parameters.Add("@C4", txtC4.Text)
cmdUp.Parameters.Add("@E1", txtE1.Text)
cmdUp.Parameters.Add("@S1", txtS1.Text)
cmdUp.Parameters.Add("@SID", lblSID.Text)
cmdUp.Parameters.Add("@TchID", varTID)
cmdUp.Parameters.Add("@CourseI*D",
Request.QueryString("CourseID"*))
conPI.Open()
cmdUp.ExecuteNonQuery()
conPI.Close()
Next
BindDataGrid()
End Sub
Nov 19 '05 #2

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

Similar topics

1
by: Tim Smith | last post by:
In my .cs code I populate set the DataSource appropriately and I can get my DataGrid to appear, though sorting throws an error 'dgDataGrid1__ctl1__ctl0' of type 'DataGridLinkButton' must be placed...
1
by: Paresh | last post by:
Hi I need to Print asp:datagrid with formatting, which will avoid my writing of crystal reports and can directly print with click of a button. I do not just want to print the current page, I...
6
by: RSB | last post by:
Hi Everyone, i am using a ASP: DataGrid control in the page and for each row i have a Delete Button Column. Every thing works fine. But now i want to add a Java script confirmation check for the...
4
by: Mark Travis | last post by:
Hi all, I have written a simple Web Application that displays a query result onto a page using the ASP DataGrid. To Digress ======= Development information about the page is as follows 1....
1
by: MrMike | last post by:
Hi. My application has dozens of datagrids but for some reason an exception occurs when one of them is updated. When a user edits a datagrid row and then clicks 'Update' the following exception...
15
by: John Blair | last post by:
Hi, Code attached but the line that gives me an error is MyDataGrid.Columns(2).Visible = False It actually gives me an error for any value instead of 2 even when 9 bound columns of data exist....
4
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a...
4
by: Jennifer | last post by:
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,...
2
by: =?Utf-8?B?RXNlbWk=?= | last post by:
I have a datatable that contains a number of web addresses as type nvarchar (eg 'www.msdn.com'). I want to use these as hyperlinks in a datagrid column. Whats the best way to do this? How can I...
2
by: getziiiiiiiiiii | last post by:
Hi There. . I need some help in paging (which is not working) in ASP:DATAGRID My Data source id is a function which returns DataTable to this datagrid. Do i need a code behind to get the next...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.