|
-
Oct 29th, 2004, 02:20 PM
#1
Thread Starter
Frenzied Member
DropDownList Error [Resolved]
I can not find a reason for this error. I have gonr as far as to remove all the code that selects an item in the ddl. Before that I also tried setting the SelectedItem.Seledted = false.
There is no code running on the page that does anything with the ddl except bind it. I preform ddl.Items.Clear() before every bind.
The page/user control that does this does it everytime. I have another page/user control that is just like the page that gets the error every time but it hardly ever gets the error.
Code:
Server Error in '/PKPromo' Application.
--------------------------------------------------------------------------------
A DropDownList cannot have multiple items selected.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A DropDownList cannot have multiple items selected.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): A DropDownList cannot have multiple items selected.]
System.Web.UI.WebControls.DropDownList.RenderContents(HtmlTextWriter writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer)
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer)
System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output)
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +72
System.Web.UI.Control.Render(HtmlTextWriter writer) +7
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +243
System.Web.UI.Page.ProcessRequestMain() +1926
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
Last edited by Magiaus; Oct 29th, 2004 at 02:36 PM.
Magiaus
If I helped give me some points.
-
Oct 29th, 2004, 02:21 PM
#2
Thread Starter
Frenzied Member
the binding code
PHP Code:
void BindDistributorsDDL()
{
this.ddl_distributors.Items.Clear();
this.ddl_distributors.Enabled = false;
Business.Contacts.DistributorCollection dc = new Business.Contacts.DistributorCollection();
if(dc.Count > 0)
{
ddl_distributors.DataSource = dc;
ddl_distributors.DataTextField = "CompanyName";
ddl_distributors.DataValueField = "Key";
this.ddl_distributors.DataBind();
this.ddl_distributors.Enabled = true;
//this.ddl_distributors.SelectedItem.Selected = false;
//this.ddl_distributors.SelectedIndex = 0;
BindDistributorRepsDDL();
}
}
void BindDistributorRepsDDL()
{
if(this.ddl_distributors.SelectedIndex != -1)
{
this.ddl_distributorRep.Items.Clear();
this.ddl_distributorRep.Enabled = false;
System.Guid g = new System.Guid(this.ddl_distributors.SelectedItem.Value);
Business.Contacts.DistributorRepCollection drc = new Business.Contacts.DistributorRepCollection(g);
if(drc.Count > 0)
{
this.ddl_distributorRep.Enabled = true;
this.ddl_distributorRep.DataSource = drc;
this.ddl_distributorRep.DataTextField = "FullNameEmail";
this.ddl_distributorRep.DataValueField = "ContactKey";
this.ddl_distributorRep.DataBind();
//this.ddl_distributorRep.SelectedItem.Selected = false;
//this.ddl_distributorRep.SelectedIndex = 0;
}
}
}
Magiaus
If I helped give me some points.
-
Oct 29th, 2004, 02:31 PM
#3
Thread Starter
Frenzied Member
I commented out the binding completely and the page loads now.
I'm not understanding this. To my mind if I set an Item to be selected or set the selected index to be x the dropdown list should deselect the selected item. Not only that but I explicitly set the selected item selected fieled = false......
Magiaus
If I helped give me some points.
-
Oct 29th, 2004, 02:36 PM
#4
Thread Starter
Frenzied Member
I found the problem. It just took me talking about it on here to figure it out. In the LoadData(key) method for my UserControl I was setting an item as selected but not setting the last selected item's selected to be false.
Magiaus
If I helped give me some points.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|