Solved

Dropdown within repeater not updating

Posted on 2016-08-22
5
16 Views
Last Modified: 2016-08-28
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

0
Comment
Question by:takwirirar
  • 3
5 Comments
 
LVL 19

Expert Comment

by:Daniel Van Der Werken
ID: 41765768
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.
0
 
LVL 8

Expert Comment

by:Prakash Samariya
ID: 41766384
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

0
 
LVL 1

Author Comment

by:takwirirar
ID: 41766515
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

0
 
LVL 1

Accepted Solution

by:
takwirirar earned 0 total points
ID: 41766761
Ok I've sorted it using the following;

<asp:DropDownList ID="DropDownList3" runat="server" DataValueField="Line" SelectedValue='<%# DataBinder.Eval(Container.DataItem, "Line") %>' DataSourceID="ProductionDataSource1" DataTextField="Line"></asp:DropDownList>
                                                        <asp:SqlDataSource ID="ProductionDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:productionConnectionString %>" SelectCommand="SELECT [Line] FROM [production_lines] ORDER BY [Line]"></asp:SqlDataSource>

Open in new window


Everything happens in the repeater now
0
 
LVL 1

Author Closing Comment

by:takwirirar
ID: 41773590
Found a workaround without using code behind
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
This video discusses moving either the default database or any database to a new volume.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now