J
Julia
Hi
I am developing a CompoisiteControl. I have problems with adding a row in my
DropDownList with the text "Select". The first time the side is opened the
"Select" row is not there. When I do a postback the row appears.
What do I do wrong?
Thanks
J
Below is some code:
protected override void CreateChildControls()
{
lblAttrAdditional.Text = "Add an attribute";
drAttrAdditional = new DropDownList();
drAttrAdditional.AutoPostBack = true;
drAttrAdditional.SelectedIndexChanged += new
EventHandler(drAttrAdditional_SelectedIndexChanged);
this.Controls.Add(drAttrAdditional);
//DataBind
if (!Page.IsPostBack)
{
BindDropDownLists();
}
}
private void BindDropDownLists()
{
dsProducts.Tables["AttributeHeader"].DefaultView.RowFilter =
"Default = '0'";
drAttrAdditional.DataSource =
dsProducts.Tables["AttributeHeader"].DefaultView;
drAttrAdditional.DataValueField = "AttrId";
drAttrAdditional.DataTextField = "Name";
drAttrAdditional.DataBind();
drAttrAdditional.Items.Insert(0, new ListItem("Select", "0"));
}
I am developing a CompoisiteControl. I have problems with adding a row in my
DropDownList with the text "Select". The first time the side is opened the
"Select" row is not there. When I do a postback the row appears.
What do I do wrong?
Thanks
J
Below is some code:
protected override void CreateChildControls()
{
lblAttrAdditional.Text = "Add an attribute";
drAttrAdditional = new DropDownList();
drAttrAdditional.AutoPostBack = true;
drAttrAdditional.SelectedIndexChanged += new
EventHandler(drAttrAdditional_SelectedIndexChanged);
this.Controls.Add(drAttrAdditional);
//DataBind
if (!Page.IsPostBack)
{
BindDropDownLists();
}
}
private void BindDropDownLists()
{
dsProducts.Tables["AttributeHeader"].DefaultView.RowFilter =
"Default = '0'";
drAttrAdditional.DataSource =
dsProducts.Tables["AttributeHeader"].DefaultView;
drAttrAdditional.DataValueField = "AttrId";
drAttrAdditional.DataTextField = "Name";
drAttrAdditional.DataBind();
drAttrAdditional.Items.Insert(0, new ListItem("Select", "0"));
}