Link to home
Start Free TrialLog in
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
ASKER CERTIFIED SOLUTION
Avatar of Habib Pourfard
Habib Pourfard
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial