I've a serieus strange problem, i try to describe it
I've a datatable, containing a collection of DVD's,
I use a dataview to order them alphabeticly, so i have at the top of my page a
collection of hyperlinks: A B C D E F G and so on
When u click on the A u got all the DVD starting with an A
Now those are placed in an editable DataGrid
So far no problems.
Now i try to edit some data of the datatable with the editcommand.
When i want to update or delete data, there is all the time taken a wrong id, so
the data isn't been changed in the right column of the dataBase but takes
another
What i'm doing wrong???
code snippet:
Sub DoItemUpdate(ByVal objSource As Object, ByVal objARgs As
DataGridCommandEventArgs)
DataGrid1.EditItemIndex = -1
Dim myIndex As Integer = objARgs.Item.DataSetIndex
'CType(CType(objARgs.Item.FindControl("lblmovieID"), Label).Text, Integer)
Dim myDS1 As DataSet = CType(Session("myDataSet"), DataSet)
Dim myDataTable As DataTable = myDS1.Tables("FilmTabel")
Dim myDataRow As DataRow = myDataTable.Rows(myIndex)
'myDataRow(0) => non editable data, stays same
'myDataRow(1) => non editable data, stays same
myDataRow(2) = CType(objARgs.Item.FindControl("txtmovieName"),
TextBox).Text.ToString '"movieName"
myDataRow(3) =
CType(CType(objARgs.Item.FindControl("txtmovieAantalDVD"), TextBox).Text,
Integer) '"movieAantalDvd"
myDataRow(4) = CType(objARgs.Item.FindControl("txtmovieFrameRate"),
TextBox).Text.ToString '"movieFrameRate => PAL?
myDataRow(5) = CType(objARgs.Item.FindControl("txtmovieCodec"),
TextBox).Text.ToString '"movieCodec => old of newer format of DVD
Session("myDataSet") = myDS1
SqlSelectCommand2.Parameters("@userID").Value = CType(txtuserID.Text,
Integer)
SqlDataAdapter2.Update(myDataTable)
BindGrid()
DataGrid1.Columns(8).Visible = False
DataGrid1.Columns(6).Visible = True
End Sub
Sub DoItemDelete(ByVal objSource As Object, ByVal objARgs As
DataGridCommandEventArgs)
Dim index As Integer = objARgs.Item.DataSetIndex
Dim myDataSet As DataSet = CType(Session("myDataSet"), DataSet)
Dim myDataTable As DataTable = myDataSet.Tables("FilmTabel")
Dim myDataRow As DataRow = myDataTable.Rows(index)
myDataTable.Rows.Remove(myDataRow)
SqlSelectCommand2.Parameters("@userID").Value = CType(txtuserID.Text,
Integer)
SqlDataAdapter2.Update(myDataSet)
DataGrid1.EditItemIndex = -1
BindGrid()
DataGrid1.Columns(6).Visible = True
DataGrid1.Columns(8).Visible = False
End Sub
***************
in the region:
***************
Me.SqlUpdateCommand2.CommandText = "[testUpdate]"
Me.SqlUpdateCommand2.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlUpdateCommand2.Connection = Me.SqlConnection2
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int,
4, System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0,
Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Param1", System.Data.SqlDbType.Int, 4,
"userID"))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieName", System.Data.SqlDbType.VarChar,
50, "movieName"))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieAantalCD", System.Data.SqlDbType.Int,
4, "movieAantalCD"))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieFrameRate",
System.Data.SqlDbType.VarChar, 10, "movieFrameRate"))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieCodec", System.Data.SqlDbType.VarChar,
10, "movieCodec"))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieID",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieID", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieAantalCD",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieAantalCD", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieCodec",
System.Data.SqlDbType.VarChar, 10,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieCodec", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieFrameRate",
System.Data.SqlDbType.VarChar, 10,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieFrameRate", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieName",
System.Data.SqlDbType.VarChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieName", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_userID",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"userID", System.Data.DataRowVersion.Original, Nothing))
Me.SqlUpdateCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@movieID", System.Data.SqlDbType.Int, 4,
"movieID"))
CType(Me.MyDS1, System.ComponentModel.ISupportInitialize).EndInit()
Me.SqlDeleteCommand2.CommandText = "[testDelete]"
Me.SqlDeleteCommand2.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlDeleteCommand2.Connection = Me.SqlConnection2
Me.SqlDeleteCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int,
4,
System.Data.ParameterDirection.ReturnValue, False, CType(0, Byte), CType(0,
Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieID",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieID", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieAantalCD",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieAantalCD", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieCodec",
System.Data.SqlDbType.VarChar, 10,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieCodec", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieFrameRate",
System.Data.SqlDbType.VarChar, 10,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieFrameRate", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_movieName",
System.Data.SqlDbType.VarChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"movieName", System.Data.DataRowVersion.Original, Nothing))
Me.SqlDeleteCommand2.Parameters.Add(New
System.Data.SqlClient.SqlParameter("@Original_userID",
System.Data.SqlDbType.Int, 4,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte),
"userID", System.Data.DataRowVersion.Original, Nothing))