I am relatively new to RadGrid and have run into a situation when editing a record in the grid. I am able to get text values in with no issue but when trying to create a dropdown list and set it's selected value to the value from the row selected I get the following error:
" 'ddlEmpType' has a SelectedValue which is invalid because it does not exist in the list of items. "
I'm not sure where my code is wrong. Here is a snippet:
<EditFormSettings EditFormType="Template">
<FormTemplate>
<table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
style="border-collapse: collapse;">
<tr class="EditFormHeader">
<td colspan="2">
<b>Employee Details</b>
</td>
</tr>
<tr>
<td>
<table id="Table3" width="450px" border="0" class="module">
<tr>
<td>Employee ID:</td>
<td>
<asp:TextBox ID="tbEmployeeID" runat="server" Text='<%# Bind("IDNUM") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td>Last Name:</td>
<td>
<asp:TextBox ID="tbLastName" runat="server" Text='<%# Bind("LASTNAME") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td>First Name:</td>
<td>
<asp:TextBox ID="tbFirstName" runat="server" Text='<%# Bind("FIRSTNAME") %>'></asp:TextBox>
</td>
</tr>
<tr>
<td>Employee Type:</td>
<td>
<asp:DropDownList ID="ddlEmpType" runat="server" SelectedValue='<%# Bind("EMP_TYPE") %>'
DataSourceID="SQL_EmpType" AppendDataBoundItems="True">
<asp:ListItem Selected="True" Text="Select" Value=""></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
<tr>
<td></td>
<td></td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update"></asp:Button>
<asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
</td>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
The datasource is set up as follows:
<asp:SqlDataSource ID="SQL_EmpType" runat="server" ConnectionString="<%$ ConnectionStrings:TECU_WS %>"
SelectCommand="SELECT DISTINCT EMP_TYPE FROM vwGetEmployees v WHERE ACTIVESTATUS is not NULL">
</asp:SqlDataSource>
Hopefully this is enough information to go on.