Hi,
I have a radgrid. I have added a dropdown in the radgrid, which is as follows:
In the Insertcommand, i am setting the value to a datatable as below:
I am getting the selected value of the dropdown. However, i am getting the below javascript error and insert is not happening.
Sys.WebForms.PageRequestManagerServerErrorException: 'ddlGender' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
How to fix this?
Thanks
I have a radgrid. I have added a dropdown in the radgrid, which is as follows:
<
ItemTemplate
>
<
asp:DropDownList
ID
=
"ddlGender"
runat
=
"server"
SelectedValue='<%# Eval("UGender") %>' />
<
asp:TextBox
ID
=
"txtUserId"
ReadOnly
=
"true"
runat
=
"server"
Text='<%# Eval("UserId") %>' />
</
ItemTemplate
>
<
InsertItemTemplate
>
<
asp:DropDownList
ID
=
"ddlGender"
runat
=
"server"
>
<
asp:ListItem
Text
=
"Male"
Value
=
"Male"
></
asp:ListItem
>
<
asp:ListItem
Text
=
"Female"
Value
=
"Female"
></
asp:ListItem
>
</
asp:DropDownList
>
<
asp:TextBox
ID
=
"txtUserId"
runat
=
"server"
></
asp:TextBox
>
</
InsertItemTemplate
>
In the Insertcommand, i am setting the value to a datatable as below:
DataTable test1 = new DataTable();
GridDataInsertItem item = (GridDataInsertItem)e.Item;
DropDownList ddlGender = (DropDownList)item.FindControl("ddlGender");
string ddlGendervalue = ddlGender.SelectedValue;
DataRow dr = test1.NewRow();
dr["UGender"] = ddlGendervalue;
test1.Rows.Add(dr);
radgridl.DataSource = this.test1;
I am getting the selected value of the dropdown. However, i am getting the below javascript error and insert is not happening.
Sys.WebForms.PageRequestManagerServerErrorException: 'ddlGender' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
How to fix this?
Thanks