Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1736
  • Last Modified:

Radiobutton and asp.net

I am having trouble with radio buttons when i click on edit. I get the error below.

Multiple controls with the same ID 'YES' were found. FindControl requires that controls have unique IDs.

I am not sure what I am doing wrong I thought that the ID was the value of the radio button in asp.net. Below is the code. Any Help would be great !!! I would give 1000 points if I could just for the sense of urgency here.

 <td valign="top">
          <asp:DetailsView AutoGenerateRows="False" DataKeyNames="id" DataSourceID="SqlDataSource3"
            HeaderText="Details" ID="DetailsView1" runat="server" Width="275px" OnItemUpdated="DetailsView1_ItemUpdated" OnItemInserted="DetailsView1_ItemInserted" OnDataBound="DetailsView1_DataBound" OnPageIndexChanging="DetailsView1_PageIndexChanging" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px" CellPadding="3" ForeColor="Black" GridLines="Vertical">
            <Fields>
              <asp:BoundField DataField="id" HeaderText="ID" ReadOnly="True" SortExpression="id" />
              <asp:BoundField DataField="QuoteID" HeaderText="QuoteID" ReadOnly="True" SortExpression="QuoteID" />
              <asp:BoundField DataField="ReferenceID" HeaderText="ReferenceID" SortExpression="ReferenceID" />
              <asp:TemplateField HeaderText="BrandedReferenceID" SortExpression="BrandedReferenceID">
                 <ItemTemplate>
                        <asp:DropDownList id="BrandedReferenceID" runat="server" DataSourceId="SqlDataSource4" DataTextField="CompanyName" DataValueField="ReferenceID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="BrokerEMailAddress" SortExpression="BrokerEMailAddress">
                 <ItemTemplate>
                        <asp:DropDownList id="BrokerEMailAddress" runat="server" DataSourceId="SqlDataSource5" DataTextField="BrokerName" DataValueField="Email_Addr" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Underwriter" SortExpression="UnderwriterID">
                 <ItemTemplate>
                        <asp:DropDownList id="Underwriter" runat="server" DataSourceId="SqlDataSource6" DataTextField="UnderwriterName" DataValueField="UnderwriterID" />
                 </ItemTemplate>
              </asp:TemplateField>
             
              <asp:TemplateField HeaderText="InsuredState" SortExpression="InsuredState">
                 <ItemTemplate>
                        <asp:DropDownList id="InsuredState" runat="server" DataSourceId="SqlDataSource2" DataTextField="StateAbbreviation" DataValueField="StateAbbreviation" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:BoundField DataField="InsuredName" HeaderText="InsuredName" SortExpression="InsuredName" />
              <asp:BoundField DataField="AdmittedSurplusLinesIndicator" HeaderText="AdmittedSurplusLinesIndicator" SortExpression="AdmittedSurplusLinesIndicator" />
              <asp:TemplateField HeaderText="AdmittedSurplusLinesIndicator" SortExpression="SingleAggregateCombinedLimitIndicator">
                 <ItemTemplate>
                     <asp:RadioButton ID="Admitted" runat="server" text="Admitted" GroupName="AdmittedSurplusLinesIndicator"/><asp:RadioButton ID="SURPLUSLINES" runat="server" text="Surplus Lines" GroupName="AdmittedSurplusLinesIndicator"/>
                 </ItemTemplate>
              </asp:TemplateField>
             
              <asp:TemplateField HeaderText="EPLLimit" SortExpression="EPLLimit">
                 <ItemTemplate>
                        <asp:DropDownList id="EPLLimit" runat="server" DataSourceId="SqlDataSource7" DataTextField="LimitAmount" DataValueField="LimitID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:BoundField DataField="EPLRetention" HeaderText="EPLRetention" SortExpression="EPLRetention" />
              <asp:BoundField DataField="EPLPremium" HeaderText="EPLPremium" SortExpression="EPLPremium" />
              <asp:BoundField DataField="EPLContinuityDate" HeaderText="EPLContinuityDate" SortExpression="EPLContinuityDate" />
              <asp:TemplateField HeaderText="EPLThirdPartyNoteShown" SortExpression="EPLThirdPartyNoteShown">
                 <ItemTemplate>
                     <asp:RadioButton ID="YES" runat="server" text="YES" GroupName="EPLThirdPartyNoteShown"/><asp:RadioButton ID="NO" runat="server" text="NO" GroupName="EPLThirdPartyNoteShown"/>
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="IPOLimit" SortExpression="IPOLimit">
                 <ItemTemplate>
                        <asp:DropDownList id="IPOLimit" runat="server" DataSourceId="SqlDataSource7" DataTextField="LimitAmount" DataValueField="LimitID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:BoundField DataField="IPORetention" HeaderText="IPORetention" SortExpression="InsuredName" />
              <asp:BoundField DataField="IPOPremium" HeaderText="IPOPremium" SortExpression="IPOPremium" />
              <asp:BoundField DataField="IPOContinuityDate" HeaderText="IPOContinuityDate" SortExpression="IPOContinuityDate" />
              <asp:TemplateField HeaderText="FiduciaryLimit" SortExpression="FiduciaryLimit">
                 <ItemTemplate>
                        <asp:DropDownList id="FiduciaryLimit" runat="server" DataSourceId="SqlDataSource7" DataTextField="LimitAmount" DataValueField="LimitID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:BoundField DataField="FiduciaryRetention" HeaderText="FiduciaryRetention" SortExpression="FiduciaryRetention" />
              <asp:BoundField DataField="FiduciaryPremium" HeaderText="FiduciaryPremium" SortExpression="FiduciaryPremium" />
              <asp:BoundField DataField="FiduciaryContinuityDate" HeaderText="FiduciaryContinuityDate" SortExpression="FiduciaryContinuityDate" />
              <asp:TemplateField HeaderText="CombinedLimit" SortExpression="CombinedLimit">
                 <ItemTemplate>
                        <asp:DropDownList id="CombinedLimit" runat="server" DataSourceId="SqlDataSource7" DataTextField="LimitAmount" DataValueField="LimitID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:BoundField DataField="CombinedRetention" HeaderText="CombinedRetention" SortExpression="CombinedRetention" />
              <asp:BoundField DataField="CombinedPremium" HeaderText="CombinedPremium" SortExpression="CombinedPremium" />
              <asp:BoundField DataField="CombinedContinuityDate" HeaderText="CombinedContinuityDate" SortExpression="CombinedContinuityDate" />
              <asp:TemplateField HeaderText="Endorsement1" SortExpression="Endorsement1">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement1" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement2" SortExpression="Endorsement2">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement2" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement3" SortExpression="Endorsement3">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement3" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement4" SortExpression="Endorsement4">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement4" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement5" SortExpression="Endorsement5">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement5" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement6" SortExpression="Endorsement6">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement6" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement7" SortExpression="Endorsement7">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement7" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement8" SortExpression="Endorsement8">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement8" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement9" SortExpression="Endorsement9">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement9" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:TemplateField HeaderText="Endorsement10" SortExpression="Endorsement10">
                 <ItemTemplate>
                        <asp:DropDownList id="Endorsement10" runat="server" DataSourceId="SqlDataSource8" DataTextField="EndorsementTitle" DataValueField="EndorsementID" />
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:BoundField DataField="Subjectivity1" HeaderText="Subjectivity1" SortExpression="Subjectivity1" />
              <asp:BoundField DataField="Subjectivity2" HeaderText="Subjectivity2" SortExpression="Subjectivity2" />
              <asp:BoundField DataField="Subjectivity3" HeaderText="Subjectivity3" SortExpression="Subjectivity3" />
              <asp:BoundField DataField="Subjectivity4" HeaderText="Subjectivity4" SortExpression="Subjectivity4" />
              <asp:BoundField DataField="Subjectivity5" HeaderText="Subjectivity5" SortExpression="Subjectivity5" />
              <asp:BoundField DataField="Subjectivity6" HeaderText="Subjectivity6" SortExpression="Subjectivity6" />
              <asp:BoundField DataField="Subjectivity7" HeaderText="Subjectivity7" SortExpression="Subjectivity7" />
              <asp:BoundField DataField="Subjectivity8" HeaderText="Subjectivity8" SortExpression="Subjectivity8" />
              <asp:BoundField DataField="Subjectivity9" HeaderText="Subjectivity9" SortExpression="Subjectivity9" />
              <asp:BoundField DataField="Subjectivity10" HeaderText="Subjectivity10" SortExpression="Subjectivity10" />
              <asp:TemplateField HeaderText="Final" SortExpression="Final">
                 <ItemTemplate>
                     <asp:RadioButton ID="YES" runat="server" text="YES" GroupName="Final"/><asp:RadioButton ID="NO" runat="server" text="NO" GroupName="Final"/>
                 </ItemTemplate>
              </asp:TemplateField>
              <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
             
            </Fields>
          </asp:DetailsView>
          <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:eRisk_ConnectionString %>"
            SelectCommand="SELECT * FROM [BookRollDetails] WHERE ([id] = @id)"
            UpdateCommand="UPDATE [BookRollDetails] SET [QuoteID] = @QuoteID, [Form] = @Form, [ReferenceID] = @ReferenceID, [BrandedReferenceID] = @BrandedReferenceID, [BrokerEMailAddress] = @BrokerEMailAddress, [UnderwriterID] = @UnderwriterID, [InsuredName] = @InsuredName, [InsuredState] = @InsuredState [AdmittedSurplusLinesIndicator] = @AdmittedSurplusLinesIndicator, [SingleAggregateCombinedLimitIndicator] = @SingleAggregateCombinedLimitIndicator [EPLLimit] = @EPLLimit [EPLRetention] = @EPLRetention, [EPLPremium] = @EPLPremium, [EPLContinuityDate] = @EPLContinuityDate, [EPLThirdPartyNoteShown] = @EPLThirdPartyNoteShown, [IPOLimit] = @IPOLimit, [IPORetention] = @IPORetention, [IPOPremium] = @IPOPremium, [IPOContinuityDate] = @IPOContinuityDate, [FiduciaryLimit] = @FiduciaryLimit, [FiduciaryRetention] = @FiduciaryRetention, [FiduciaryPremium] = @FiduciaryPremium, [FiduciaryContinuityDate] = @FiduciaryContinuityDate, [CombinedLimit] = @CombinedLimit, [CombindRetention] = @CombindRetention, [CombinedContinuityDate] = @CombinedContinuityDate, [Endorsement1] = @Endorsement1, [Endorsement2] = @Endorsement2, [Endorsement3] = @Endorsement3, [Endorsement4] = @Endorsement4, [Endorsement5] = @Endorsement5, [Endorsement6] = @Endorsement6, [Endorsement7] = @Endorsement7, [Endorsement8] = @Endorsement8, [Endorsement9] = @Endorsement9, [Endorsement10] = @Endorsement10, [Subjectivity1] = @Subjectivity1, [Subjectivity2] = @Subjectivity2, [Subjectivity3] = @Subjectivity3, [Subjectivity4] = @Subjectivity4, [Subjectivity5] = @Subjectivity5, [Subjectivity6] = @Subjectivity6, [Subjectivity7] = @Subjectivity7, [Subjectivity8] = @Subjectivity8, [Subjectivity9] = @Subjectivity9, [Subjectivity10] = @Subjectivity10, [Final] = @Final WHERE [id] = @id"
            InsertCommand="INSERT INTO [BookRollDetails] ([QuoteID], [Form], [ReferenceID], [address], [city], [state], [zip], [contract]) VALUES (@au_id, @au_lname, @au_fname, @phone, @address, @city, @state, @zip, @contract)">
            <SelectParameters>
              <asp:ControlParameter ControlID="GridView1" Name="id" PropertyName="SelectedValue"
                Type="String" />
            </SelectParameters>
            <UpdateParameters>
              <asp:Parameter Name="QuoteID" Type="String" />
              <asp:Parameter Name="ReferenceID" Type="String" />
              <asp:Parameter Name="BrandedReferenceID" Type="String" />
              <asp:Parameter Name="BrokerEMailAddress" Type="String" />
              <asp:Parameter Name="UnderwriterID" Type="String" />
              <asp:Parameter Name="InsuredState" Type="String" />
              <asp:Parameter Name="InsuredName" Type="String" />
              <asp:Parameter Name="AdmittedSurplusLinesIndicator" Type="String" />
              <asp:Parameter Name="SingleAggregateCombinedLimitIndicator" Type="String" />
              <asp:Parameter Name="EPLLimit" Type="String" />
              <asp:Parameter Name="EPLRetention" Type="String" />
              <asp:Parameter Name="EPLPremium" Type="String" />
              <asp:Parameter Name="EPLContinuityDate" Type="String" />
              <asp:Parameter Name="EPLThirdPartyNoteShown" Type="String" />
              <asp:Parameter Name="IPOLimit" Type="String" />
              <asp:Parameter Name="IPORetention" Type="String" />
              <asp:Parameter Name="IPOPremium" Type="String" />
              <asp:Parameter Name="IPOContinuityDate" Type="String" />
              <asp:Parameter Name="FiduciaryLimit" Type="String" />
              <asp:Parameter Name="FiduciaryRetention" Type="String" />
              <asp:Parameter Name="FiduciaryPremium" Type="String" />
              <asp:Parameter Name="FiduciaryContinuityDate" Type="String" />
              <asp:Parameter Name="CombinedLimit" Type="String" />
              <asp:Parameter Name="CombinedRetention" Type="String" />
              <asp:Parameter Name="CombinedPremium" Type="String" />
              <asp:Parameter Name="CombinedContinuityDate" Type="String" />
              <asp:Parameter Name="Endorsement1" Type="String" />
              <asp:Parameter Name="Endorsement2" Type="String" />
              <asp:Parameter Name="Endorsement3" Type="String" />
              <asp:Parameter Name="Endorsement4" Type="String" />
              <asp:Parameter Name="Endorsement5" Type="String" />
              <asp:Parameter Name="Endorsement6" Type="String" />
              <asp:Parameter Name="Endorsement7" Type="String" />
              <asp:Parameter Name="Endorsement8" Type="String" />
              <asp:Parameter Name="Endorsement9" Type="String" />
              <asp:Parameter Name="Endorsement10" Type="String" />
              <asp:Parameter Name="Subjectivity1" Type="String" />
              <asp:Parameter Name="Subjectivity2" Type="String" />
              <asp:Parameter Name="Subjectivity3" Type="String" />
              <asp:Parameter Name="Subjectivity4" Type="String" />
              <asp:Parameter Name="Subjectivity5" Type="String" />
              <asp:Parameter Name="Subjectivity6" Type="String" />
              <asp:Parameter Name="Subjectivity7" Type="String" />
              <asp:Parameter Name="Subjectivity8" Type="String" />
              <asp:Parameter Name="Subjectivity9" Type="String" />
              <asp:Parameter Name="Subjectivity10" Type="String" />
              <asp:Parameter Name="Final" Type="String" />
            </UpdateParameters>
            <InsertParameters>
              <asp:Parameter Name="QuoteID" Type="String" />
              <asp:Parameter Name="ReferenceID" Type="String" />
              <asp:Parameter Name="BrandedReferenceID" Type="String" />
              <asp:Parameter Name="BrokerEMailAddress" Type="String" />
              <asp:Parameter Name="UnderwriterID" Type="String" />
              <asp:Parameter Name="InsuredState" Type="String" />
              <asp:Parameter Name="InsuredName" Type="String" />
              <asp:Parameter Name="AdmittedSurplusLinesIndicator" Type="String" />
              <asp:Parameter Name="SingleAggregateCombinedLimitIndicator" Type="String" />
              <asp:Parameter Name="EPLLimit" Type="String" />
              <asp:Parameter Name="EPLRetention" Type="String" />
              <asp:Parameter Name="EPLPremium" Type="String" />
              <asp:Parameter Name="EPLContinuityDate" Type="String" />
              <asp:Parameter Name="EPLThirdPartyNoteShown" Type="String" />
              <asp:Parameter Name="IPOLimit" Type="String" />
              <asp:Parameter Name="IPORetention" Type="String" />
              <asp:Parameter Name="IPOPremium" Type="String" />
              <asp:Parameter Name="IPOContinuityDate" Type="String" />
              <asp:Parameter Name="FiduciaryLimit" Type="String" />
              <asp:Parameter Name="FiduciaryRetention" Type="String" />
              <asp:Parameter Name="FiduciaryPremium" Type="String" />
              <asp:Parameter Name="FiduciaryContinuityDate" Type="String" />
              <asp:Parameter Name="CombinedLimit" Type="String" />
              <asp:Parameter Name="CombinedRetention" Type="String" />
              <asp:Parameter Name="CombinedPremium" Type="String" />
              <asp:Parameter Name="CombinedContinuityDate" Type="String" />
              <asp:Parameter Name="Endorsement1" Type="String" />
              <asp:Parameter Name="Endorsement2" Type="String" />
              <asp:Parameter Name="Endorsement3" Type="String" />
              <asp:Parameter Name="Endorsement4" Type="String" />
              <asp:Parameter Name="Endorsement5" Type="String" />
              <asp:Parameter Name="Endorsement6" Type="String" />
              <asp:Parameter Name="Endorsement7" Type="String" />
              <asp:Parameter Name="Endorsement8" Type="String" />
              <asp:Parameter Name="Endorsement9" Type="String" />
              <asp:Parameter Name="Endorsement10" Type="String" />
              <asp:Parameter Name="Subjectivity1" Type="String" />
              <asp:Parameter Name="Subjectivity2" Type="String" />
              <asp:Parameter Name="Subjectivity3" Type="String" />
              <asp:Parameter Name="Subjectivity4" Type="String" />
              <asp:Parameter Name="Subjectivity5" Type="String" />
              <asp:Parameter Name="Subjectivity6" Type="String" />
              <asp:Parameter Name="Subjectivity7" Type="String" />
              <asp:Parameter Name="Subjectivity8" Type="String" />
              <asp:Parameter Name="Subjectivity9" Type="String" />
              <asp:Parameter Name="Subjectivity10" Type="String" />
              <asp:Parameter Name="Final" Type="String" />
0
-cr-
Asked:
-cr-
  • 2
  • 2
1 Solution
 
deanvanrooyenCommented:
hi

with xhtml every control must have a unique id here is your issue change the second id to something slightly different.


                     <asp:RadioButton ID="YES" runat="server" text="YES" GroupName="EPLThirdPartyNoteShown"/>
                     <asp:RadioButton ID="YES" runat="server" text="YES" GroupName="Final"/>
0
 
-cr-Author Commented:
Isnt the ID the value of the radiobutton ?
0
 
-cr-Author Commented:
We would like the Value of YES or No to be inserted accordingly....I must be missing something.

<asp:RadioButton ID="YES" runat="server" text="YES" GroupName="EPLThirdPartyNoteShown"/>
<asp:RadioButton ID="NO" runat="server" text="YES" GroupName="EPLThirdPartyNoteShown"/>
<asp:RadioButton ID="YES" runat="server" text="YES" GroupName="Final"/>
<asp:RadioButton ID="NO" runat="server" text="YES" GroupName="Final"/>
0
 
GavinMannionCommented:
No ID is not the value... ID is the Identifier...

The Value of a checkbox is either Checked or UnChecked... Basically Checked="true" or Checked="false"

So change your code to

<asp:RadioButton ID="rbEPLThirdPartyNoteShownYes" checked="true" runat="server" text="YES" GroupName="EPLThirdPartyNoteShown"/>
<asp:RadioButton ID="rbEPLThirdPartyNoteShownNo" checked="false" runat="server" text="YES" GroupName="EPLThirdPartyNoteShown"/>
0
 
deanvanrooyenCommented:
hi cr

you are thinking of classic asp - with asp.net this is not the case -  you MUST have unique id's, what you do is if the checkbox is in a grid eg

                  <asp:TemplateColumn HeaderText="Allow">
                      <ItemTemplate>
                         <asp:CheckBox ID="rolecheck" runat="server"></asp:CheckBox>
                      </ItemTemplate>
                  </asp:TemplateColumn>

then you can check if it is checked like so

                foreach (DataGridItem dgi in this.DataGrid1.Items)
                {
                    CheckBox b = (CheckBox)dgi.FindControl("rolecheck");

                    if (b.Checked)
                    {
                         .....
                    }
                }

or you might handle a selected row but you basically do the same thing...
CheckBox b = (CheckBox)dgi.FindControl("rolecheck");

that is why you need unique id's - findcontrol uses the id to find the correct control....
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now