Avatar of Codingitup
Codingitup
 asked on

set selectedindex of a DropDownList within a repeater. ASP.net C#

Hi All,

I've got the following code within a repeater control: -

                    <asp:Repeater ID="Repeater1" runat="server" 
                        DataSourceID="sqlDBGetRoutingPath" ClientIDMode="Static" 
                        EnableTheming="False"
                            >
                        <HeaderTemplate>
                        <table border="0" cellpadding="0">
                        </HeaderTemplate>
                        <ItemTemplate>

                            <tr align="center">
                                <td rowspan="2" style="background-color: #FFCC00; width: 189px; border-bottom-style: groove;">
                                    <asp:Label ID="lblRoutingSeq" runat="server" Font-Bold="True" 
                                        Font-Names="Arial Black" Font-Size="XX-Large" Text="0"></asp:Label>
                                </td>
                                <td rowspan="2" style="background-color: #CCCCCC; width: 380px; border-bottom-style: groove;">
                                    <asp:DropDownList ID="cmdStage" runat="server" Width="95%" BackColor="White">
                                    </asp:DropDownList>
                                </td>
                                <td rowspan="2" style="background-color: #CCCCCC; width: 380px;; border-bottom-style: groove;">
                                    <asp:DropDownList  ID="cmbReturnStage" runat="server" Width="95%" BackColor="White" DataSourceID="sqlDBStages" DataTextField="Stages" 
                                                    DataValueField="StageRefID">
                                    </asp:DropDownList>
                                </td>
                                <td style="background-color: #CCCCCC; width: 80px;">
                                    <asp:CheckBox ID="chkMating" runat="server" Text="Mating" />
                                </td>
                            </tr>
                            <tr>
                                <td style="background-color: #CCCCCC ; border-bottom-style: groove;"">
                                    <asp:ImageButton ID="cmdMoveUp" runat="server" Height="24px" 
                                        ImageUrl="~/Images/up.png" Width="24px" />
                                    <asp:ImageButton ID="cmdMoveDown" runat="server" Height="24px" 
                                        ImageUrl="~/Images/down.png" Width="24px" />
                                    <asp:ImageButton ID="cmdDelete" runat="server" Height="24px" 
                                        ImageUrl="~/Images/gtk_cancel.png" Width="24px" />
                                </td>
                            </tr>

                        </ItemTemplate>
                        <FooterTemplate>
                        </table>
                        </FooterTemplate>

                    </asp:Repeater>

Open in new window


There is a repeated control called cmbReturnStage which is a DropDownList. They are all populated by a certain list. I've got another bit of code that will set the selectedindex of the drop down list but how do I go about setting the SelectedIndex property please when it is within a repeater.

Many Thanks
Lee
C#ASP.NET

Avatar of undefined
Last Comment
Habib Pourfard

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Habib Pourfard

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck