Advertisement

06.02.2008 at 11:48AM PDT, ID: 23450890
[x]
Attachment Details

ASP.NET - adding a databound dropdownlist during runtime

Asked by josephdaviskcrm in .NET Framework 2.0, Visual Studio .NET 2005

I have successfully added a databound dropdownlist to my site via standard design...
--------------------.aspx----------------------------------------------------------------------------------
<asp:SqlDataSource ID="sdsSelectReport" runat="server" ConnectionString="<%$connectionStrings:ConnectionString %>" DataSourceMode="DataSet"></asp:SqlDataSource>
            <asp:DropDownList ID="ddlSelectReport" runat="server" DataSourceID="sdsSelectReport" DataTextField="HierarchyDesc" DataValueField="HierarchyID" AppendDataBoundItems="true">
                <asp:ListItem Text="All Users" Value="AllUsers" Selected="true"></asp:ListItem>
            </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="<%$connectionStrings:ConnectionString %>" DataSourceMode="DataSet"></asp:SqlDataSource>
--------------------------------------.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
[+][-]06.02.2008 at 01:11PM PDT, ID: 21695232

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET Framework 2.0, Visual Studio .NET 2005
Sign Up Now!
Solution Provided By: MakarandSKolhe
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628