Link to home
Start Free TrialLog in
Avatar of David C
David CFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Dropdown within repeater not updating

Hi,

I have a Dropdownlist inside a repeater that is not updating. I am getting error

An unhandled exception of type 'System.StackOverflowException' occurred in System.Data.dll

Open in new window


My design is as follows

<asp:DropDownList ID="DropDownList3" runat="server" DataValueField="Line" SelectedValue='<%#DataBinder.Eval(Container.DataItem, "Line")%>' OnDataBinding="getLines"></asp:DropDownList>

Open in new window


Code is

Protected Sub getLines(sender As Object, e As System.EventArgs)
        Dim DropDownList3 As DropDownList = DirectCast(sender, DropDownList)

        Dim cmd As SqlDataAdapter = New SqlDataAdapter("select Line from dbo.production_lines order by Line", cnn)
        Dim ds As DataSet = New DataSet()
        cmd.Fill(ds)

        DropDownList3.DataSource = ds
        DropDownList3.DataTextField = ("Line")
        DropDownList3.DataBind()

        ds.Clear()
        cmd.Dispose()
End Sub

Open in new window

Avatar of Daniel Van Der Werken
Daniel Van Der Werken
Flag of United States of America image

You say there is a repeater in the title but I don't see any repeater defined or code for it in the code behind.
Please check if DataSet fills or not! Error shows "It could not finds the list", and you are trying to assig its' value.

Try below code
<asp:DropDownList ID="DropDownList3" runat="server" OnDataBinding="getLines">/asp:DropDownList>

Open in new window

Back-End
Protected Sub getLines(sender As Object, e As System.EventArgs)
        Dim DrpList3 As DropDownList = DirectCast(sender, DropDownList)

        Dim cmd As SqlDataAdapter = New SqlDataAdapter("select Line from dbo.production_lines order by Line", cnn)
        Dim ds As DataSet = New DataSet()
        cmd.Fill(ds)

        DrpList3.DataSource = ds
        DrpList3.DataBind()

        ds.Clear()
        cmd.Dispose()
End Sub

Open in new window

Avatar of David C

ASKER

Daniel, the repeater is as follows;

<table style="width: 100%;">

                                        <asp:Repeater ID="Repeater1" runat="server">
                                            <HeaderTemplate>

                                                <tr>
                                                    <td>Line</td>
                                                    <td>Role</td>
                                                    <td>Name</td>
                                                    <td>Level</td>
                                                    <td>Present</td>
                                                </tr>

                                            </HeaderTemplate>

                                            <ItemTemplate>
                                                <tr>
                                                    <td>
                                                        <asp:DropDownList ID="DropDownList3" runat="server" DataValueField="Line" SelectedValue='<%#DataBinder.Eval(Container.DataItem, "Line")%>' OnDataBinding="getLines"></asp:DropDownList>
                                                    </td>
                                                    <td>
                                                        <asp:DropDownList ID="DropDownList4" runat="server" DataValueField="Role" SelectedValue='<%#DataBinder.Eval(Container.DataItem, "Role")%>' OnDataBinding="getRoles"></asp:DropDownList>
                                                    </td>
                                                    <td>
                                                        <asp:DropDownList ID="DropDownList5" runat="server" DataValueField="Name" SelectedValue='<%#DataBinder.Eval(Container.DataItem, "Name")%>' OnDataBinding="getNames"></asp:DropDownList>
                                                    </td>
                                                    <td>
                                                        <asp:DropDownList ID="DropDownList6" runat="server" DataValueField="Level" SelectedValue='<%#DataBinder.Eval(Container.DataItem, "Level")%>' OnDataBinding="getLevels"></asp:DropDownList>
                                                    </td>
                                                    <td>
                                                        <asp:CheckBox ID="CheckBox1" runat="server" />
                                                    </td>
                                                </tr>
                                            </ItemTemplate>
                                        </asp:Repeater>
                                    </table>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of David C
David C
Flag of United Kingdom of Great Britain and Northern Ireland 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
Avatar of David C

ASKER

Found a workaround without using code behind