gi11ies
Programmer
- Mar 26, 2002
- 52
Hi
Im displaying a datalist with each row having an ID, name and a checkbox - what I want to do is if the checkbox is checked then insert the ID for that row into the database.
I can not get the value for inserting the ID for the selected row in the datagrid into the database.
The code I am using is as follows:
Dim dgItem as DataGridItem
Dim chkAdd as System.Web.UI.WebControls.CheckBox
Dim i as Integer
For i = ferDG.Items.Count-1 To 0 Step -1
chkAdd = CType(ferDG.Items(i).FindControl("itemCheck"), CheckBox)
If chkAdd.checked then
Dim ferMsgConn1 As OleDbConnection
Dim ferConn1 As String
ferConn1 = ConfigurationSettings.AppSettings("connString")
ferMsgConn1 = New OleDbConnection(ferConn1)
ferMsgConn1.Open
Dim ferSQL1 as String = "insert into recipients (message_id, to_id, status) values ('13', '" & CType(ferDG.Items(i).FindControl("uid"),String) & "', 'Pending')"'('" & Session("uid") & "','" & Session("fullname") & "','" & Session("location") & "','" & Session("location") & "')"
Dim ferCmd1 as New OleDbCommand(ferSQL1, ferMsgConn1)
ferCmd1.ExecuteNonQuery()
ferMsgConn1.Close
Response.Redirect("msgs_read.aspx")
End If
Next
The failing code is:
CType(ferDG.Items(i).FindControl("uid"),String)
Any tips on how to get this to work would be great.
Gillies
Im displaying a datalist with each row having an ID, name and a checkbox - what I want to do is if the checkbox is checked then insert the ID for that row into the database.
I can not get the value for inserting the ID for the selected row in the datagrid into the database.
The code I am using is as follows:
Dim dgItem as DataGridItem
Dim chkAdd as System.Web.UI.WebControls.CheckBox
Dim i as Integer
For i = ferDG.Items.Count-1 To 0 Step -1
chkAdd = CType(ferDG.Items(i).FindControl("itemCheck"), CheckBox)
If chkAdd.checked then
Dim ferMsgConn1 As OleDbConnection
Dim ferConn1 As String
ferConn1 = ConfigurationSettings.AppSettings("connString")
ferMsgConn1 = New OleDbConnection(ferConn1)
ferMsgConn1.Open
Dim ferSQL1 as String = "insert into recipients (message_id, to_id, status) values ('13', '" & CType(ferDG.Items(i).FindControl("uid"),String) & "', 'Pending')"'('" & Session("uid") & "','" & Session("fullname") & "','" & Session("location") & "','" & Session("location") & "')"
Dim ferCmd1 as New OleDbCommand(ferSQL1, ferMsgConn1)
ferCmd1.ExecuteNonQuery()
ferMsgConn1.Close
Response.Redirect("msgs_read.aspx")
End If
Next
The failing code is:
CType(ferDG.Items(i).FindControl("uid"),String)
Any tips on how to get this to work would be great.
Gillies