David C
asked on
Dropdown within repeater not updating
Hi,
I have a Dropdownlist inside a repeater that is not updating. I am getting error
My design is as follows
Code is
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
My design is as follows
<asp:DropDownList ID="DropDownList3" runat="server" DataValueField="Line" SelectedValue='<%#DataBinder.Eval(Container.DataItem, "Line")%>' OnDataBinding="getLines"></asp:DropDownList>
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
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
Try below code
<asp:DropDownList ID="DropDownList3" runat="server" OnDataBinding="getLines">/asp:DropDownList>
Back-EndProtected 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
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>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Found a workaround without using code behind