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">
                                                              <Columns>
                                                                  <telerik:GridBoundColumn UniqueName="TestID" HeaderText="TestID" DataField="TestID">
                                                                  </telerik:GridBoundColumn>
                                                                  <telerik:GridBoundColumn UniqueName="Gender" HeaderText="Gender" DataField="Gender">
                                                                  </telerik:GridBoundColumn>                                                          
                                                                  <telerik:GridEditCommandColumn HeaderText="Edit">
                                                                  </telerik:GridEditCommandColumn>
                                                                  <telerik:GridButtonColumn CommandName="Delete" Text="Delete" HeaderText="Delete">
                                                                  </telerik:GridButtonColumn>
                                                              </Columns>
                                                              <EditFormSettings EditFormType="Template">
                                                                  <FormTemplate>
                                                                      <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                                                                          style="border-collapse: collapse;">
                                                                          <tr>
                                                                              <td>
                                                                                  <table id="Table3" width="450px" border="0" class="module">
                                                                                      <tr>
                                                                                          <td style="text-align: center;">TestID :
                                                                                          </td>
                                                                                          <td>
                                                                                              <asp:DropDownList ID="rddlTestID" runat="server" SelectedValue='<%#  Bind("TestID")  %>'
                                                                                                  DataSourceID="rddlTestIDSource" DataTextField="TestID" DataValueField="TestID" AppendDataBoundItems="True">
                                                                                                  <asp:ListItem Selected="True" Text="Select" Value="">
                                                                                                  </asp:ListItem>
                                                                                              </asp:DropDownList>
     
                                                                                          </td>
                                                                                      </tr>
                                                                                      <tr>
                                                                                          <td style="text-align: center;">Gender :
                                                                                          </td>
                                                                                          <td>
                                                                                              <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>
                                                                                              </asp:RadioButtonList>
                                                                                          </td>
                                                                                      </tr>                                                                                 
     
                                                                                  </table>
                                                                              </td>
                                                                          </tr>
                                                                          <tr>
                                                                              <td colspan="2"></td>
                                                                          </tr>
                                                                          <tr>
                                                                              <td></td>
                                                                              <td></td>
                                                                          </tr>
                                                                          <tr>
                                                                              <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>
                                                                              </td>
                                                                          </tr>
                                                                      </table>
                                                                  </FormTemplate>
                                                              </EditFormSettings>
                                                          </MasterTableView>                                                     
                                                      </telerik:RadGrid>
                                                  </telerik:RadPageView>
    <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">
                                              <InsertParameters>
                                                  <asp:Parameter Name="TestID" Type="String" />
                                                  <asp:Parameter Name="Gender" Type="String" />                                             
                                              </InsertParameters>
                                              <UpdateParameters>
                                                  <asp:Parameter Name="Gender" Type="string" />                                           
                                                  <asp:Parameter Name="TestID" Type="String" />
                                              </UpdateParameters>
                                              <DeleteParameters>
                                                  <asp:Parameter Name="TestID" Type="String" />
                                              </DeleteParameters>
                                          </asp:SqlDataSource>


    Can anyone help me out with this error?

    Thanks in advance.

    Regards,
    Ruchi Patel
  2. Eyup
    Admin
    Eyup avatar
    3015 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.

    Regards,
    Eyup
    Telerik
     

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top