I have a web user control name as Chart Control, and I have a drop down List inside Chart Control I want to populate DropDown List of Chart Control like this:
<UC:ChartControl ID="abc" runat="server">
<ChartDropDownItems>
<asp:ListItem Text="Graph_Amount_Items_Sold" Value="0"></asp:ListItem>
<asp:ListItem Text="Graph_Ranking" Value="1"></asp:ListItem>
<asp:ListItem Text="Graph_Share_Amount_Items_Sold" Value="2"></asp:ListItem>
<asp:ListItem Text="Graph_Share_Unit_items_Sold" Value="3" Selected="True"></asp:ListItem>
<asp:ListItem Text="Graph_Unit_items_Sold" Value="4"></asp:ListItem>
</ChartDropDownItems>
</UC:ChartControl>
in .cs code
[DefaultProperty("ChartDropDownItems"),
ParseChildren(true, "ChartDropDownItems"), PersistChildren(false),
ToolboxData("<{0}:ChartControl runat=\"server\"> </{0}:ChartControl>")]
public partial class ChartControl : System.Web.UI.UserControl
{
private List<ListItem> lst;
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
public List<ListItem> ChartDropDownItems
{
set
{
lst = value;
Bind_ddChartChange();
}
}
private void Bind_ddChartChange()
{
if (lst != null)
{
ddChartChange.DataSource = lst;
ddChartChange.DataTextField = "Text";
ddChartChange.DataValueField = "Value";
ddChartChange.DataBind();
ListItem li = lst.Find(x => x.Selected == true);
ddChartChange.SelectedValue = li.Value;
}
}
}
When I compile and run it works fine for me, but at design time it says
"Error Creating Control"
"Type'System.Web.UI.Control' does not have a public property named 'ChartDropDownItems'"
I want to work it even at design time. Can any body suggest me accordingly ? Thanks.