I have successfully added a databound dropdownlist to my site via standard design...
--------------------.aspx-
----------
----------
----------
----------
----------
----------
----------
----------
-
<asp:SqlDataSource ID="sdsSelectReport" runat="server" ConnectionString="<%$conne
ctionStrin
gs:Connect
ionString %>" DataSourceMode="DataSet"><
/asp:SqlDa
taSource>
<asp:DropDownList ID="ddlSelectReport" runat="server" DataSourceID="sdsSelectRep
ort" DataTextField="HierarchyDe
sc" DataValueField="HierarchyI
D" AppendDataBoundItems="true
">
<asp:ListItem Text="All Users" Value="AllUsers" Selected="true"></asp:List
Item>
</asp:DropDownList>
However, I am trying to create the same dropdownlist in memory during runtime and add it to a table cell. The dropdownlist shows up in the table cell, but it is not databound. Its just an empty dropdownlist.
--------------------------
----------
.aspx-----
----------
----------
----------
--------
<asp:SqlDataSource ID="sdsLevelSelection" runat="server" ConnectionString="<%$conne
ctionStrin
gs:Connect
ionString %>" DataSourceMode="DataSet"><
/asp:SqlDa
taSource>
--------------------------
----------
--.aspx.vb
----------
----------
----------
----------
---------
rowcell = New TableCell
ddl = New DropDownList
ddl.ID = "ddlLevelSelect" & x.ToString()
ddl.DataSource = "sdsLevelSelection"
ddl.DataTextField = "HierarchyDesc"
ddl.DataValueField = "HierarchyID"
rowcell.Controls.Add(ddl)
tblrow.Cells.Add(rowcell)
--------------------------
----------
----------
----------
----------
----------
-----
Any hints?
Start Free Trial