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);
}
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);
}