D
David C
I have a drop down list control where I set AppendDataBound to true and
The new name is stored in a hidden TextBox and in the Load event I use it to
add the record to the lookup table. Below is the block of code in the Load
event of the FormView.
Dim row As FormViewRow = fvTrademark.Row
Dim varControl
Dim lngNewID As Long = 0
Dim lngTradeID As Long = fvTrademark.DataKey.Value
varControl = row.FindControl("ddlAgentID")
If varControl.SelectedValue = -1 Then
'Run class function to create new record in
tlkpAgent and return ID
lngNewID =
DBClass.CreateNewtlkpAgent(txtNewText.Text, lngTradeID, False)
'set dropdownlist selectedvalue to new agentid
varControl.SelectedValue = lngNewID.ToString
txtNewText.Text = ""
Exit Select
End If
The DBClass function creates a new record in the lookup table (which is used
as the DataSource for the drop down list (ddlAgentID). The error occurs
trying to set the SelectedValue of the control. The error is below:
'ddlAgentID' has a SelectedValue which is invalid because it does not exist
in the list of items.
David
The new name is stored in a hidden TextBox and in the Load event I use it to
add the record to the lookup table. Below is the block of code in the Load
event of the FormView.
Dim row As FormViewRow = fvTrademark.Row
Dim varControl
Dim lngNewID As Long = 0
Dim lngTradeID As Long = fvTrademark.DataKey.Value
varControl = row.FindControl("ddlAgentID")
If varControl.SelectedValue = -1 Then
'Run class function to create new record in
tlkpAgent and return ID
lngNewID =
DBClass.CreateNewtlkpAgent(txtNewText.Text, lngTradeID, False)
'set dropdownlist selectedvalue to new agentid
varControl.SelectedValue = lngNewID.ToString
txtNewText.Text = ""
Exit Select
End If
The DBClass function creates a new record in the lookup table (which is used
as the DataSource for the drop down list (ddlAgentID). The error occurs
trying to set the SelectedValue of the control. The error is below:
'ddlAgentID' has a SelectedValue which is invalid because it does not exist
in the list of items.
David