Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 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 February 16th, 2006, 11:55 PM
Registered User
 
Join Date: Feb 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default wrapping IF statement around DropDownList

Hi,

Is there a way to wrap an IF condition around a DropDownList, I don't want the dropdown to appear in all rows, only in some rows.

I tried wrapping a script around the asp DropDownList declaration, but it gives me compile errors:

<script language="c#" runat="server">
  <asp:DropDownList ID="dDropList" blah blah
                    runat="server">
  </asp:DropDownList>
</script>

Any suggestions on how i can wrap an IF statement around the <asp:DropDownList declaration?

Thanks!

 
Old February 17th, 2006, 09:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

You can't do that... It's not like the ASP way of doing things. You do one of a few things; use panels to show/hide controls based on certain parameters. Another thing you can do is to dynamically create the control through code:

if (..) then
  Dim objList as new DropDownList
  ContainerControl.Controls.Add(objList) 'a panel or some other container
end if

There are a variety of ways to do things. What do you want to do?

Brian
 
Old February 17th, 2006, 09:48 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You can also switch the Visible property based on some condition

asp:DropDownList ID="dDropList" runat="server" Visible=<%# SomeMethod %>'>
</asp:DropDownList>

where SomeMethod is a boolean function in your Code Behind...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 20th, 2006, 02:45 AM
Registered User
 
Join Date: Feb 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar! that was exactly what I was looking for!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Text wrapping abhilasha_dubey JSP Basics 1 October 26th, 2007 12:03 AM
Wrapping Report arholly Access 1 May 10th, 2007 06:32 AM
Word wrapping hbenditsky VB How-To 0 February 6th, 2006 08:19 AM
"Text-wrapping" bcat BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 1 March 28th, 2005 11:53 PM





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