Hi,
I have a DropDown list which I Initialize in "CreateChildControls" and add to the controls collections. I then override the render method and then render the drop down list. The web part inherits from System.Web.UI.WebControls.WebParts.WebPart.
I bind the drop down list in my web part like this
private void BindClientTypes()
        {
            DataTable dt = DB.GetAllClientTypes();
            if (dt == null)
            {
                ltGlobalErrorMsg.Text = GlobalErrorMessage;
                ltGlobalErrorMsg.Visible = true;
            }
            else
            {
                ddlClient.DataSource = dt;
                ddlClient.DataValueField = "ID";
                ddlClient.DataTextField = "Name";
                ddlClient.DataBind();
                ddlClient.Items.Insert(0, PleaseSelectItem);
            }
        }
If I try to set the selected index of the drop down list after the data bind, I get an error which says the control cannot have multiple selected items.
The code works fine, means that I can set the selected index after the data bind if I comment this line
//ddlClient.Items.Insert(0, PleaseSelectItem);
Can anyone give any explanation on why this would work.
Thanks