Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Casting a FindControl in C#?


Message #1 by "Oliver, Wells" <WOliver@l...> on Fri, 11 Oct 2002 08:22:34 -0700
In VB.NET I have:
CType (E.Item.FindControl ("results"), Dropdownlist).Items.Add (new Listitem
(OptionItem, Microsoft.VisualBasic.Left (OptionItem, 1)))

I am trying to do the same thing in C# and not really getting anywhere..
e.g.:
(DropDownList)e.Item.FindControl ("results").Items.Add (OptionItem, "Err");

Any tips? Thanks!

Wells Oliver
Web Application Programmer
Leviton Voice & Data
xxx-xxx-xxxx
http://www.levitonvoicedata.com

Message #2 by Ali Ahmad H <aheryana@b...> on Sat, 12 Oct 2002 08:32:45 +0700
Try this :

your code : (DropDownList)e.Item.FindControl ("results").Items.Add 
(OptionItem, "Err");

new code : ((DropDownList)e.Item.FindControl ("results")).Items.Add 
(OptionItem, "Err");

regards,
-ali-

At 08:22 AM 10/11/2002 -0700, you wrote:
>In VB.NET I have:
>CType (E.Item.FindControl ("results"), Dropdownlist).Items.Add (new Listitem
>(OptionItem, Microsoft.VisualBasic.Left (OptionItem, 1)))
>
>I am trying to do the same thing in C# and not really getting anywhere..
>e.g.:
>(DropDownList)e.Item.FindControl ("results").Items.Add (OptionItem, "Err");
>
>Any tips? Thanks!
>
>Wells Oliver
>Web Application Programmer
>Leviton Voice & Data
>xxx-xxx-xxxx
>http://www.levitonvoicedata.com
>
>
>---
>
>ASP.NET 1.0 Namespace Reference with C#
>http://www.wrox.com/acon11.asp?ISBN=1861007442
>
>ASP.NET 1.0 Namespace Reference with VB.NET
>http://www.wrox.com/acon11.asp?ISBN=1861007450
>
>These books are a complete reference to the ASP.NET namespaces
>for developers who are already familiar with using ASP.NET.
>There is no trivial introductory material or useless .NET
>hype and the presentation of the namespaces, in an easy-to use
>alphabetical order ensures a user-friendly reference format.
>We provide in-depth coverage of all the major ASP.NET classes,
>giving you those real-world tips that the documentation doesn't
>offer, and demonstrating complex techniques with simple
>examples.
>
>---

regards,
-ali-

http://www.aliahmad.net


  Return to Index