I'm having such a problem with this DropDownList in a user control that is
posting back and throwing an error: System.Web.Http Exception: A
DropDownList cannot have multiple items selected
<ASP:DROPDOWNLI ST ID="lbCountries Wiz" ENABLEVIEWSTATE ="true" FONT-SIZE="8pt"
ONSELECTEDINDEX CHANGED="ddlQue ryProvinces"
AUTOPOSTBACK="T rue" RUNAT="server" WIDTH="150px"></ASP:DROPDOWNLIS T>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Dim tempItem3 As New System.Web.UI.W ebControls.List Item
tempItem3.Text = "Chad"
tempItem3.Value = "TD"
tempItem3.Selec ted = False
Me.lbCountriesW iz.Items.Insert (0, tempItem3)
Dim tempItem2 As New System.Web.UI.W ebControls.List Item
tempItem2.Text = "Bosnia and Herzegovina"
tempItem2.Value = "BA"
tempItem2.Selec ted = False
Me.lbCountriesW iz.Items.Insert (0, tempItem2)
Dim tempItem As New System.Web.UI.W ebControls.List Item
tempItem.Text = "|--None Selected"
tempItem.Value = "0"
tempItem.Select ed = False
lbCountriesWiz. Items.Insert(0, tempItem)
End If
End Sub
When a button in the same user control is pushed and then I reselect the
DropDownList, I don't get the error.
<ASP:BUTTON ID="btnAllCommu nities"
ONCLICK="btnPop ulateAllCommuni ties_OnClick" FONT-SIZE="8"
RUNAT="server" TEXT="All Communities" BORDERSTYLE="in set"></ASP:BUTTON>
Public Sub btnPopulateAllC ommunities_OnCl ick(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles btnAllCommuniti es.Click
'These simply fill some other listboxes
GetProvinces()
GetDistricts()
GetSubDistricts ()
GetCommunities( )
End Sub
When buttons (such as below) in the controling Page are pushed and then I
try to reselect the DropDownList, I get the error.
<ASP:BUTTON id="btn1" onclick="GetRep ort1_OnClick" RUNAT="server" TEXT="Get
report of" HEIGHT="20"
FONT-SIZE="10px"></ASP:BUTTON>
Sub GetReport1_OnCl ick(ByVal Sender As Object, ByVal e As System.EventArg s)
Try
dgSHA.Visible = False
dgShasSum.Visib le = False
dgCommunity.Vis ible = True
dgCommunitiesSu m.Visible = True
ShowButtons()
'pnlCommunities Buttons.Visible = True
Dim _sqlStmtR1 As String
_sqlStmtR1 = "SELECT * FROM vwCommunities WHERE countryID = '" &
CType(Page,
_default1).choo seAdminUnitsWiz 1.lbCountriesWi z.SelectedItem. Value & "' "
If ddlImpactLevel1 .SelectedItem.V alue <> "All" Then
_sqlStmtR1 = _sqlStmtR1 & " AND Impact = '" &
ddlImpactLevel1 .SelectedItem.V alue & "'"
End If
'_sqlStmtR1 = _sqlStmtR1 & " ORDER BY Community"
Dim myDataSetCommun ities1 As New DataSet
Dim myDataAdapterCo mmunities1 As New SqlDataAdapter( _sqlStmtR1,
connection1.con String)
myDataAdapterCo mmunities1.Fill (myDataSetCommu nities1,
"CommunitiesTmp 1")
dgCommunity.Dat aSource =
myDataSetCommun ities1.Tables(" CommunitiesTmp1 ")
dgCommunity.Dat aBind()
CommunitiesWizS qlSumStatement( 1)
Dim myDataSetCommun itiesSum As New DataSet
Dim myDataAdapterCo mmunitiesSum As New
SqlDataAdapter( _sqlStmtLbCommu nitiesWizSum, connection1.con String)
myDataAdapterCo mmunitiesSum.Fi ll(myDataSetCom munitiesSum,
"CommunitiesSum Tmp1")
dgCommunitiesSu m.DataSource =
myDataSetCommun itiesSum.Tables ("CommunitiesSu mTmp1")
dgCommunitiesSu m.DataBind()
RecordCount2.Te xt = ""
RecordCount3.Te xt = ""
RecordCount4.Te xt = ""
RecordCount5.Te xt = ""
RecordCount6.Te xt = ""
Dim RcdCount As Integer
Dim ResultCount As Integer
RcdCount =
myDataSetCommun ities1.Tables(" CommunitiesTmp1 ").Rows.Count.T oString()
ResultCount = RcdCount
RecordCount1.Te xt = RcdCount & " records"
RecordCountBott om.Text = RcdCount & " records"
Session("savedD ataGridSql") = _sqlStmtR1
Session("dgType ") = "Community"
Me.sortCriteria = "Community"
Me.sortDir = "ASC"
If Session("dgType ") = "Community" Then
pnlCommunitiesB uttons.Visible = True
pnlShasButtons. Visible = False
Else
pnlCommunitiesB uttons.Visible = False
pnlShasButtons. Visible = True
End If
Catch ex As Exception
ExceptionManage r.Publish(ex)
End Try
End Sub 1 6332
You've shown a lot of code, too much and too spread out to be too useful.
But the error speaks for itself, somewhere you are setting two selected
values to the dropdown and this isn't allowed. My guess is that it's
beeing set in the Page_Load and being set elsewhere on one of the many
button postbacks.... You'll simply need to debug and/or simplify your code
to get to the root of it.
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"DC Gringo" <dc******@visio ntechnology.net > wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. . I'm having such a problem with this DropDownList in a user control that is posting back and throwing an error: System.Web.Http Exception: A DropDownList cannot have multiple items selected
<ASP:DROPDOWNLI ST ID="lbCountries Wiz" ENABLEVIEWSTATE ="true" FONT-SIZE="8pt" ONSELECTEDINDEX CHANGED="ddlQue ryProvinces" AUTOPOSTBACK="T rue" RUNAT="server" WIDTH="150px"></ASP:DROPDOWNLIS T>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here
If Not Page.IsPostBack Then
Dim tempItem3 As New System.Web.UI.W ebControls.List Item tempItem3.Text = "Chad" tempItem3.Value = "TD" tempItem3.Selec ted = False Me.lbCountriesW iz.Items.Insert (0, tempItem3)
Dim tempItem2 As New System.Web.UI.W ebControls.List Item tempItem2.Text = "Bosnia and Herzegovina" tempItem2.Value = "BA" tempItem2.Selec ted = False Me.lbCountriesW iz.Items.Insert (0, tempItem2)
Dim tempItem As New System.Web.UI.W ebControls.List Item tempItem.Text = "|--None Selected" tempItem.Value = "0" tempItem.Select ed = False lbCountriesWiz. Items.Insert(0, tempItem)
End If
End Sub When a button in the same user control is pushed and then I reselect the DropDownList, I don't get the error.
<ASP:BUTTON ID="btnAllCommu nities" ONCLICK="btnPop ulateAllCommuni ties_OnClick" FONT-SIZE="8" RUNAT="server" TEXT="All Communities" BORDERSTYLE="in set"></ASP:BUTTON>
Public Sub btnPopulateAllC ommunities_OnCl ick(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles btnAllCommuniti es.Click
'These simply fill some other listboxes
GetProvinces() GetDistricts() GetSubDistricts () GetCommunities( )
End Sub
When buttons (such as below) in the controling Page are pushed and then I try to reselect the DropDownList, I get the error.
<ASP:BUTTON id="btn1" onclick="GetRep ort1_OnClick" RUNAT="server" TEXT="Get report of" HEIGHT="20" FONT-SIZE="10px"></ASP:BUTTON>
Sub GetReport1_OnCl ick(ByVal Sender As Object, ByVal e As System.EventArg s)
Try
dgSHA.Visible = False dgShasSum.Visib le = False dgCommunity.Vis ible = True dgCommunitiesSu m.Visible = True
ShowButtons()
'pnlCommunities Buttons.Visible = True
Dim _sqlStmtR1 As String _sqlStmtR1 = "SELECT * FROM vwCommunities WHERE countryID = '" & CType(Page, _default1).choo seAdminUnitsWiz 1.lbCountriesWi z.SelectedItem. Value & "' "
If ddlImpactLevel1 .SelectedItem.V alue <> "All" Then _sqlStmtR1 = _sqlStmtR1 & " AND Impact = '" & ddlImpactLevel1 .SelectedItem.V alue & "'" End If '_sqlStmtR1 = _sqlStmtR1 & " ORDER BY Community"
Dim myDataSetCommun ities1 As New DataSet Dim myDataAdapterCo mmunities1 As New SqlDataAdapter( _sqlStmtR1, connection1.con String) myDataAdapterCo mmunities1.Fill (myDataSetCommu nities1, "CommunitiesTmp 1") dgCommunity.Dat aSource = myDataSetCommun ities1.Tables(" CommunitiesTmp1 ") dgCommunity.Dat aBind()
CommunitiesWizS qlSumStatement( 1)
Dim myDataSetCommun itiesSum As New DataSet Dim myDataAdapterCo mmunitiesSum As New SqlDataAdapter( _sqlStmtLbCommu nitiesWizSum, connection1.con String) myDataAdapterCo mmunitiesSum.Fi ll(myDataSetCom munitiesSum, "CommunitiesSum Tmp1") dgCommunitiesSu m.DataSource = myDataSetCommun itiesSum.Tables ("CommunitiesSu mTmp1") dgCommunitiesSu m.DataBind()
RecordCount2.Te xt = "" RecordCount3.Te xt = "" RecordCount4.Te xt = "" RecordCount5.Te xt = "" RecordCount6.Te xt = ""
Dim RcdCount As Integer Dim ResultCount As Integer RcdCount = myDataSetCommun ities1.Tables(" CommunitiesTmp1 ").Rows.Count.T oString() ResultCount = RcdCount RecordCount1.Te xt = RcdCount & " records" RecordCountBott om.Text = RcdCount & " records"
Session("savedD ataGridSql") = _sqlStmtR1 Session("dgType ") = "Community" Me.sortCriteria = "Community" Me.sortDir = "ASC" If Session("dgType ") = "Community" Then pnlCommunitiesB uttons.Visible = True pnlShasButtons. Visible = False Else pnlCommunitiesB uttons.Visible = False pnlShasButtons. Visible = True End If
Catch ex As Exception ExceptionManage r.Publish(ex) End Try
End Sub This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: dhnriverside |
last post by:
Hi guys
Still having a problem with this dropdownlist.
Basically, I've got 4. The first 2 work fine, then my code crashes on the
3rd.
ddlEndTimeHour.Items.FindByValue(endTime).Selected = true;
Where endTime is a string containing "15".
|
by: DC Gringo |
last post by:
I'm having such a problem with this DropDownList in a user control that is
posting back and throwing an error: System.Web.HttpException: A
DropDownList cannot have multiple items selected
<ASP:DROPDOWNLIST ID="lbCountriesWiz" ENABLEVIEWSTATE="true" FONT-SIZE="8pt"
ONSELECTEDINDEXCHANGED="ddlQueryProvinces"
AUTOPOSTBACK="True" RUNAT="server" WIDTH="150px"></ASP:DROPDOWNLIST>
Private Sub Page_Load(ByVal sender As System.Object, ByVal...
|
by: g |
last post by:
I have a user control that contains a dropdownlist. Using a public
property, I can get the selected item. However, I am unsure of how to use
that same public property to set the selected item. Here's my code:
private string m_item = "";
public string Item
{
get
{
|
by: ads |
last post by:
hi,
after binding the dropdownlist to a datasource, ive experience this error
"Cannot have multiple items selected in a dropdownlist" after using the code:
dropdownlist.items.findbyvalue("value").selected = true
I didnt specify any selected item in the dropdownlist during binding to the
datasource. I use dropdownlist.clearselection() but still error occurs.
I need information on this. Thanks.
Ads
|
by: Ben |
last post by:
I have a formview with a few dropdownlists (software version, database
version, etc). When a software version is selected, the database version
dropdownlist updates itself accordingly. When in edit mode, everything works
fine - the selected value in each list defaults to the value from the
database record (selectedvalue=bind...).
However, in insert mode (insertitem), it is not working. I pass in a value
on the query string that I would...
| |
by: Lou Civitella |
last post by:
I have two drop down list boxes on my asp page. The boxes store a country
value on my page. They are filled by code during the load event and then I
set their values in code from a table on a SQL server. If the values are the
same then all is OK but if the values happen to be different I get this
error
Cannot have multiple items selected in a DropDownList.
I cannot fiugre out why this keeps happening. I have two other DropDownList
boxes...
|
by: rn5a |
last post by:
I am binding a DropDownList with records existing in a database table.
I want to add an extra item *SELECT COMPANY* at index 0 so that by
default, it gets selected. This is how I tried it but the extra item
just doesn't get added to the DropDownList:
=============================================
<script runat="server">
Sub Page_Load(..........)
Dim dSet As DataSet
Dim sqlConn As SqlConnection
|
by: =?Utf-8?B?S3Jpc2huYQ==?= |
last post by:
Hi,
I am devloping one web application using .net framework 2.0.One page has
7 dropdown list control.When i update the values first bind the values to
the drop down llist then selected text using findbytext method.I got the
following error
ERROR: Cannot have multiple items selected in a DropDownList.
Coding is below
|
by: mylog |
last post by:
Hi
I am having a problem of getting the value from the dynamically generated table and dropdownlist. What I am facing is, I have created a table in the aspx page and now I need to add values to the the cells of the table respectively which I have done easily but the problem is when I add the dynamically generated dropdownlist to the cell I cannot read the value from the dropdownlist.
For adding the dropdownlist in the cell I have done the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |