470,842 Members | 1,361 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,842 developers. It's quick & easy.

Custom Server Control Property

I wrote a simple server control that inherits from the DropDownList
control. I will be using the control in an aspx page and want to
access it in a repeater. I have created a public property called
DefaultValue. For some reason, the property is never set from within
my aspx page. It just gets ignored. Does anyone know why?

Here is how it looks in my aspx:

<frmcontrol:controltypedropdown DefaultValue="5"
id="Controltypedropdown1" runat="server"/>

Below is my control code.

namespace blah.Controls

/// <summary>
/// A server control to display the dropdown of Control Types. Will
/// displayed programatically in a repeater.
/// </summary>
public class ControlTypeDropDown :
private DataTable dt;
private ListItem[] coll;

private string defaultValue="0";
public string DefaultValue
get{return defaultValue;}

public ControlTypeDropDown() : base()
Survey s = new Survey();
dt = s.GetFormControls();
coll = new ListItem[dt.Rows.Count+1];
coll[0] = new ListItem("", "0");
for(int i=0;i<dt.Rows.Count;i++)
coll[i+1] = new ListItem(Convert.ToString(dt.Rows[i]["type"]),

HttpContext.Current.Application.Add("ControlTypeDr opDown", coll);
coll = (ListItem[])HttpContext.Current.Application["ControlTypeDropDown"];

this.Items.FindByValue(DefaultValue).Selected=true ;

Nov 17 '05 #1
0 917

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Joe | last post: by
3 posts views Thread by Chris Newby | last post: by
1 post views Thread by Jeremy Chapman | last post: by
3 posts views Thread by Tomasz J | last post: by
4 posts views Thread by =?Utf-8?B?UmljaEI=?= | last post: by
reply views Thread by mihailmihai484 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.