Radiobuttonlist Issue with Radgrid usingForm template Edit form

2 posts, 0 answers
  1. Ruchi
    Ruchi avatar
    54 posts
    Member since:
    Apr 2012

    Posted 05 Feb 2015 Link to this post

    Hello Team,

    We are using Rad grid with Form template  edit form, we need to place Radio button list with 2 options "Male" and "Female" for gender inside FormTemplate.

    Please find Error below:
    Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: 'rbtGender' has a SelectedValue which is invalid because it does not exist in the list of items.<br>Parameter name: value

    Code below:
    <telerik:RadGrid ID="rgDemoRestrictedTests" runat="server" CssClass="RadGrid" GridLines="None" AllowPaging="True" PageSize="20" AllowSorting="True"
                                                          AutoGenerateColumns="false" ShowStatusBar="true" AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
                                                          DataSourceID="DemoRestrictedTestsSource" OnItemDeleted="rgDemoRestrictedTests_ItemDeleted" OnItemInserted="rgDemoRestrictedTests_ItemInserted"
                                                          OnItemUpdated="rgDemoRestrictedTests_ItemUpdated" OnItemCommand="rgDemoRestrictedTests_ItemCommand">
                                                          <MasterTableView CommandItemDisplay="Bottom" DataSourceID="DemoRestrictedTestsSource" DataKeyNames="TestID">
                                                                  <telerik:GridBoundColumn UniqueName="TestID" HeaderText="TestID" DataField="TestID">
                                                                  <telerik:GridBoundColumn UniqueName="Gender" HeaderText="Gender" DataField="Gender">
                                                                  <telerik:GridEditCommandColumn HeaderText="Edit">
                                                                  <telerik:GridButtonColumn CommandName="Delete" Text="Delete" HeaderText="Delete">
                                                              <EditFormSettings EditFormType="Template">
                                                                      <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                                                                          style="border-collapse: collapse;">
                                                                                  <table id="Table3" width="450px" border="0" class="module">
                                                                                          <td style="text-align: center;">TestID :
                                                                                              <asp:DropDownList ID="rddlTestID" runat="server" SelectedValue='<%#  Bind("TestID")  %>'
                                                                                                  DataSourceID="rddlTestIDSource" DataTextField="TestID" DataValueField="TestID" AppendDataBoundItems="True">
                                                                                                  <asp:ListItem Selected="True" Text="Select" Value="">
                                                                                          <td style="text-align: center;">Gender :
                                                                                              <asp:RadioButtonList runat="server" ID="rbtGender" RepeatDirection="Horizontal" DataValueField="Gender" SelectedValue='<%#  Bind("Gender") %>'>
                                                                                                  <asp:ListItem Text="Male" Value="Male" Selected="True"></asp:ListItem>
                                                                                                  <asp:ListItem Text="Female" Value="Female"></asp:ListItem>
                                                                              <td colspan="2"></td>
                                                                              <td align="rifht" colspan="2">
                                                                                  <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                                                                      runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button
                                                                           <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>
    <asp:SqlDataSource runat="server" ID="DemoRestrictedTestsSource" ConnectionString="x" ProviderName="System.Data.SqlClient"
                                              SelectCommand="Select [TestID], (case when [Gender] = 0 then 'Male' else 'Female' end) as [Gender] From [TestUtil_DemoRestrictedTests]"
                                              InsertCommand="Insert Into [TestUtil_DemoRestrictedTests] Values ('@TestID', (case when @Gender = 'Male' then 1 else 0 end))"
                                              UpdateCommand="Update [TestUtil_DemoRestrictedTests] Set [Gender] = (case when @Gender = 'Male' then 0 else 1 end) Where [TestID] = @TestID"
                                              DeleteCommand="DELETE FROM [TestUtil_DemoRestrictedTests] WHERE [TestID] = @TestID">
                                                  <asp:Parameter Name="TestID" Type="String" />
                                                  <asp:Parameter Name="Gender" Type="String" />                                             
                                                  <asp:Parameter Name="Gender" Type="string" />                                           
                                                  <asp:Parameter Name="TestID" Type="String" />
                                                  <asp:Parameter Name="TestID" Type="String" />

    Can anyone help me out with this error?

    Thanks in advance.

    Ruchi Patel
  2. Eyup
    Eyup avatar
    3320 posts

    Posted 10 Feb 2015 Link to this post

    Hello Ruchi,

    The error indicates that the value returned from the Bind("Gender") evaluation contains some different value than the initial defined options - Male and Female. This may be caused by some invalid or empty data. Can you please temporarily replace the RadioButtonList with a regular TextBox and use its Text property to set the binding expression. Thus, you will be able to check whether the returned values match as expected.

    Hope this helps.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top