Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 16th, 2004, 08:43 AM
Registered User
 
Join Date: Mar 2004
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dynamically generate DropDownList

Hi ,
    Following code is not working. I need to generate a DropDownList dynamically and add it into a cell.


TableCell c6 = new TableCell();
                    c6.Controls.Add(new LiteralControl("<asp:DropDownList id=DropDownList" + i.ToString() + " runat='server' DataSource='<%# getChargedStatus() %>' DataTextField='vchrChargedStatus' DataValueField='intChargedStatusID'></asp:dropdownlist>"));
                    r.Cells.Add(c6);


Satya

 
Old June 17th, 2004, 02:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

It wont work since u r going to make a text of included ASP.NET controls in ur HTML. I sueggest to make a <SELECT> tag in order to make it much easy...

HTH,
Keep in touch in every faced problem.

Always:),
Hovik Melkomian.
 
Old June 17th, 2004, 01:20 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

You can do this, but instead of adding literal HTML you need to add an actual control.

TableCell c6 = new TableCell();
DropDownList ddlMyDDL = new DropDownList();
ddlMyDDL.ID = "DropDownList" + i.ToString();
c6.Controls.Add(ddlMyDDL);
ddlMyDDL.DataSource = getChargedStatus
ddlMyDDL.DataTextField = "vchrChargedStatus";
ddlMyDDL.DataValueField = "intChargedStatusID";
ddlMyDDL.DataBind();
r.Cells.Add(c6);





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically generated dropdownlist csun ASP.NET 1.0 and 1.1 Basics 3 April 8th, 2008 07:38 AM
dynamically generate crystal report s_sanks Crystal Reports 0 March 3rd, 2008 07:19 AM
Binding DropDownList Dynamically knight1907 ASP.NET 2.0 Basics 5 April 4th, 2006 09:01 AM
Populating Dropdownlist in Datagrid Dynamically anup_daware .NET Framework 1.x 1 March 27th, 2006 03:38 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.