I have a selection criteria that pulls a selection of records (as few as 2, as many as 98)associated with a user and displays them in a GridView. There is also a drop down list that is in the GridView, which is used to make a selection. Then the user clicks on the Save button, with the intent of returning back their selections to the data base.
The issue I am having oddly enough isn't with the embedded grid view drop down, or even getting it to write to the data base. The issue I am having is writing to the correct location as I'm failing to properly grab the recordID that the drop down selection should be writing to. When the user selects to update, it will be to multiple records.
recordID (needs to be read to direct the recordDropDown selected value to the proper record)
recordDetail (does not get returned, data contained is used in the decision process for selecting the recordDropDown value)
recordDropDown (needs to be written to the appropriate recordID row in the database)
Your help is greatly appreciated.
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim cmd As New SqlCommand
cmd.Connection = cn
Dim gvr As GridViewRow
Dim ddl As New DropDownList
For Each gvr In gvSelection.Rows
If gvr.RowType = DataControlRowType.DataRow Then
ddl = CType(gvr.FindControl("gvddl"), DropDownList)
cmd.CommandText = "spUPDRecord"
cmd.CommandType = CommandType.StoredProcedure
'Everything Ive used here so far in the XXX has failed, this is where Im trying to pass the RecordID back to ensure the correct record is updated.'
lblSuccess.Visible = True
lblSuccess.Text = "You have successfully added the selections to the database"
Catch ex As Exception
lblerror.Visible = True
lblerror.ForeColor = System.Drawing.Color.Red
lblerror.Text = "An error has occurred. Please contact the webmaster and provide the error message listed below:<br /><br />" & ex.Message
If Not cn Is Nothing Then cn.Close()