please help me with a dropdownlist selectindexchange event into a custom control

K

KMILO

Hello,

Im inserting a dropdownlist into a custom control, I fills it up, change the
autopostback property to true, and finally assign the handler to do this
event into the control, but in runtime I change the items and nothing
happends, any ideas about how to do that correctly, what Im missing?

Thanks in advance.

KMILO.

ps: heres the code:

//setting up the control
private DropDownList MonthsDropDown()
{
foreach (string MonthName in DateTimeFormatInfo.CurrentInfo.MonthNames)
{
if (MonthName != String.Empty)
{
ddlMonths.Items.Add(MonthName);
}
}
ddlMonths.Items.FindByValue(DateTime.Now.ToString("MMMM")).Selected = true;
return ddlMonths;
}

//assign the control to the htmltextwriter and the selectindexchange
protected override void Render(HtmlTextWriter html)
{

_dtSource = null;
if (this.DataSource != null && this.DayField != null)
{
if (this.DataSource is DataTable)
_dtSource = (DataTable) this.DataSource;
if (this.DataSource is DataSet)
{
DataSet ds = (DataSet) this.DataSource;
if (this.DataMember == null || this.DataMember == "")
_dtSource = ds.Tables[0];
else
_dtSource = ds.Tables[this.DataMember];
}
if (_dtSource == null)
throw new Exception("Error finding the DataSource. Please check " +
" the DataSource and DataMember properties.");
}
if (ShowMonthsInDrop)
{
this.ShowTitle = false;
ddlMonths.AutoPostBack = true;
ddlMonths.SelectedIndexChanged +=new
EventHandler(ddlMonths_SelectedIndexChanged);
this.MonthsDropDown().RenderControl(html);
}
base.Render(html);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,099
Messages
2,570,626
Members
47,237
Latest member
David123

Latest Threads

Top