Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Basics
| Search | Today's Posts | Mark Forums Read
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 January 19th, 2004, 11:53 PM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default selected value from dropdownlist control

Hi,

i have been creating dynamic dropdownlist control using *.ascx with codebehind. the dropdownlist resides within a placeholder.

I am unable to retrieve the values from the custom control. Please let mi know the soln.

Thnks :D
 
Old January 20th, 2004, 12:16 AM
Authorized User
 
Join Date: Dec 2003
Location: sg petani, kedah, Malaysia.
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to suzila
Default

hi,

i'm new in programming, but I try my best to understand your question.

Do u mean:

You want to get a value, after u have select one of item in dropdownlist?

If yes, I can show one of my example..

you must set one variable like

uid1 = DropDownList1.SelectedItem.Value


That's all...


 
Old January 20th, 2004, 12:25 AM
Registered User
 
Join Date: Jan 2004
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

tat's not quite the soln i am looking for....
the dynamic creation of controls as follows:

for(int i = 0; i < _numControl; i++)
{
  int temp;
  temp = i+1;
  LiteralControl lcLabel = new LiteralControl();
  lcLabel.Text = temp + ". ";
  plHolder.Controls.Add(lcLabel);
  DropDownList ddl = new DropDownList();
  ddl.ID = "ddlSort" + i;
  foreach(DictionaryEntry obj in _dataSrc)
  {
     ListItem lstItem = new ListItem();
     lstItem.Value = (string)obj.Key;
     lstItem.Text = (string)obj.Value;
     ddl.Items.Add(lstItem);
  }
  ddl.Items.FindByText(_strDefault[i]).Selected=true;
  plHolder.Controls.Add(ddl);
  LiteralControl lcBr = new LiteralControl();
  lcBr.Text = "<br>";
  plHolder.Controls.Add(lcBr);
}

when the page is posted over to the server, i am unable to retrieve the values of the selections.

i have tried using plHolder.FindControl("ddlSort" + i).SelectedItem.Value, it does not work.

Anyone have faced tis problem before n found a soln?

 
Old January 20th, 2004, 09:29 AM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Where and how are you executing that chunk of code? If you create the list every time, you can't access the selected items for it.

Describe what you are trying to do in general terms and perhaps we can provide a suggestion on how to do it better with .net controls.

Peter
------------------------------------------------------
Work smarter, not harder.




Similar Threads
Thread Thread Starter Forum Replies Last Post
find the selected index of the dropdownlist suneet.pant ASP.NET 2.0 Basics 0 May 22nd, 2008 03:45 AM
read the selected value of DropDownList from VBScr dbayona ASP.NET 2.0 Professional 0 November 11th, 2007 06:16 PM
How to set selected item in Dropdownlist? MTLedari ASP.NET 2.0 Basics 4 December 27th, 2006 12:53 AM
unable to get selected value form dropdownlist swati_joshi ASP.NET 1.0 and 1.1 Basics 3 March 31st, 2006 12:35 PM
DropDownList Selected Index = -1?? dorothee ASP.NET 1.0 and 1.1 Basics 4 June 11th, 2004 03:08 AM





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