D
dave
I have a datagrid with checkboxes for each row.
The user is able to select the ones he wants, then hit a "Save" button,
which then loops through them all and insert the checked ones into a DB.
At the moment i am using the following code to do it, which is assigning the
ID of the record to the "text" value of the checkbox, then i am using this
to insert the correct records into the DB.
My question is: - is it possible to do this using the Datakeyfield value,
which is also set in the dgrid to record ID for each row - as my solution is
not ideal, as the user can see the ID's assigned to the checkbox text if
they highlight the grid/page. I have come across some articles which use the
hidden column method...
Any pointer/code examples would be much appreciated....
Cheers
'///////////////////////////////////////////////////////////////////////////
////////////
Sub InsertAssigned()
Dim GridItem As System.Web.UI.WebControls.DataGridItem
Dim chkBox as System.Web.UI.WebControls.CheckBox
Dim SQLUpdate as String
For Each GridItem In dgBrowser.Items
chkBox = GridItem.FindControl("SELECTED_ITEMS")
If chkBox.Checked Then
SQLUpdate = "INSERT INTO dbo.COURSE_GROUPS_LIST ( COURSE_GROUP_ID,
COURSE_ROOT_ID, "
SQLUpdate = SQLUpdate & "ADDED_BY_USER_ID, LICENSE_ID ) "
SQLUpdate = SQLUpdate & "VALUES "
SQLUpdate = SQLUpdate & "( " & "" & SelectedID & ", "
SQLUpdate = SQLUpdate & "'" & System.Convert.ToInt32(chkBox.Text) & "', "
SQLUpdate = SQLUpdate & "'" & Session("USER_ID") & "', "
SQLUpdate = SQLUpdate & "'" & Session("LICENSE_ID") & "' ) "
MiscFunctions.SQLNonQuery( SQLUpdate )
End If
Next
End Sub
The user is able to select the ones he wants, then hit a "Save" button,
which then loops through them all and insert the checked ones into a DB.
At the moment i am using the following code to do it, which is assigning the
ID of the record to the "text" value of the checkbox, then i am using this
to insert the correct records into the DB.
My question is: - is it possible to do this using the Datakeyfield value,
which is also set in the dgrid to record ID for each row - as my solution is
not ideal, as the user can see the ID's assigned to the checkbox text if
they highlight the grid/page. I have come across some articles which use the
hidden column method...
Any pointer/code examples would be much appreciated....
Cheers
'///////////////////////////////////////////////////////////////////////////
////////////
Sub InsertAssigned()
Dim GridItem As System.Web.UI.WebControls.DataGridItem
Dim chkBox as System.Web.UI.WebControls.CheckBox
Dim SQLUpdate as String
For Each GridItem In dgBrowser.Items
chkBox = GridItem.FindControl("SELECTED_ITEMS")
If chkBox.Checked Then
SQLUpdate = "INSERT INTO dbo.COURSE_GROUPS_LIST ( COURSE_GROUP_ID,
COURSE_ROOT_ID, "
SQLUpdate = SQLUpdate & "ADDED_BY_USER_ID, LICENSE_ID ) "
SQLUpdate = SQLUpdate & "VALUES "
SQLUpdate = SQLUpdate & "( " & "" & SelectedID & ", "
SQLUpdate = SQLUpdate & "'" & System.Convert.ToInt32(chkBox.Text) & "', "
SQLUpdate = SQLUpdate & "'" & Session("USER_ID") & "', "
SQLUpdate = SQLUpdate & "'" & Session("LICENSE_ID") & "' ) "
MiscFunctions.SQLNonQuery( SQLUpdate )
End If
Next
End Sub