Solved

Dropdown within repeater not updating

Posted on 2016-08-22
5
19 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 20

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

20 Experts available now in Live!

Get 1:1 Help Now