D
DC Gringo
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
ROPDOWNLIST ID="lbCountriesWiz" ENABLEVIEWSTATE="true" FONT-SIZE="8pt"
ONSELECTEDINDEXCHANGED="ddlQueryProvinces"
AUTOPOSTBACK="True" RUNAT="server" WIDTH="150px"></ASP
ROPDOWNLIST>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Dim tempItem3 As New System.Web.UI.WebControls.ListItem
tempItem3.Text = "Chad"
tempItem3.Value = "TD"
tempItem3.Selected = False
Me.lbCountriesWiz.Items.Insert(0, tempItem3)
Dim tempItem2 As New System.Web.UI.WebControls.ListItem
tempItem2.Text = "Bosnia and Herzegovina"
tempItem2.Value = "BA"
tempItem2.Selected = False
Me.lbCountriesWiz.Items.Insert(0, tempItem2)
Dim tempItem As New System.Web.UI.WebControls.ListItem
tempItem.Text = "|--None Selected"
tempItem.Value = "0"
tempItem.Selected = 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="btnAllCommunities"
ONCLICK="btnPopulateAllCommunities_OnClick" FONT-SIZE="8"
RUNAT="server" TEXT="All Communities" BORDERSTYLE="inset"></ASP:BUTTON>
Public Sub btnPopulateAllCommunities_OnClick(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnAllCommunities.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="GetReport1_OnClick" RUNAT="server" TEXT="Get
report of" HEIGHT="20"
FONT-SIZE="10px"></ASP:BUTTON>
Sub GetReport1_OnClick(ByVal Sender As Object, ByVal e As System.EventArgs)
Try
dgSHA.Visible = False
dgShasSum.Visible = False
dgCommunity.Visible = True
dgCommunitiesSum.Visible = True
ShowButtons()
'pnlCommunitiesButtons.Visible = True
Dim _sqlStmtR1 As String
_sqlStmtR1 = "SELECT * FROM vwCommunities WHERE countryID = '" &
CType(Page,
_default1).chooseAdminUnitsWiz1.lbCountriesWiz.SelectedItem.Value & "' "
If ddlImpactLevel1.SelectedItem.Value <> "All" Then
_sqlStmtR1 = _sqlStmtR1 & " AND Impact = '" &
ddlImpactLevel1.SelectedItem.Value & "'"
End If
'_sqlStmtR1 = _sqlStmtR1 & " ORDER BY Community"
Dim myDataSetCommunities1 As New DataSet
Dim myDataAdapterCommunities1 As New SqlDataAdapter(_sqlStmtR1,
connection1.conString)
myDataAdapterCommunities1.Fill(myDataSetCommunities1,
"CommunitiesTmp1")
dgCommunity.DataSource =
myDataSetCommunities1.Tables("CommunitiesTmp1")
dgCommunity.DataBind()
CommunitiesWizSqlSumStatement(1)
Dim myDataSetCommunitiesSum As New DataSet
Dim myDataAdapterCommunitiesSum As New
SqlDataAdapter(_sqlStmtLbCommunitiesWizSum, connection1.conString)
myDataAdapterCommunitiesSum.Fill(myDataSetCommunitiesSum,
"CommunitiesSumTmp1")
dgCommunitiesSum.DataSource =
myDataSetCommunitiesSum.Tables("CommunitiesSumTmp1")
dgCommunitiesSum.DataBind()
RecordCount2.Text = ""
RecordCount3.Text = ""
RecordCount4.Text = ""
RecordCount5.Text = ""
RecordCount6.Text = ""
Dim RcdCount As Integer
Dim ResultCount As Integer
RcdCount =
myDataSetCommunities1.Tables("CommunitiesTmp1").Rows.Count.ToString()
ResultCount = RcdCount
RecordCount1.Text = RcdCount & " records"
RecordCountBottom.Text = RcdCount & " records"
Session("savedDataGridSql") = _sqlStmtR1
Session("dgType") = "Community"
Me.sortCriteria = "Community"
Me.sortDir = "ASC"
If Session("dgType") = "Community" Then
pnlCommunitiesButtons.Visible = True
pnlShasButtons.Visible = False
Else
pnlCommunitiesButtons.Visible = False
pnlShasButtons.Visible = True
End If
Catch ex As Exception
ExceptionManager.Publish(ex)
End Try
End Sub
posting back and throwing an error: System.Web.HttpException: A
DropDownList cannot have multiple items selected
<ASP
ONSELECTEDINDEXCHANGED="ddlQueryProvinces"
AUTOPOSTBACK="True" RUNAT="server" WIDTH="150px"></ASP
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Dim tempItem3 As New System.Web.UI.WebControls.ListItem
tempItem3.Text = "Chad"
tempItem3.Value = "TD"
tempItem3.Selected = False
Me.lbCountriesWiz.Items.Insert(0, tempItem3)
Dim tempItem2 As New System.Web.UI.WebControls.ListItem
tempItem2.Text = "Bosnia and Herzegovina"
tempItem2.Value = "BA"
tempItem2.Selected = False
Me.lbCountriesWiz.Items.Insert(0, tempItem2)
Dim tempItem As New System.Web.UI.WebControls.ListItem
tempItem.Text = "|--None Selected"
tempItem.Value = "0"
tempItem.Selected = 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="btnAllCommunities"
ONCLICK="btnPopulateAllCommunities_OnClick" FONT-SIZE="8"
RUNAT="server" TEXT="All Communities" BORDERSTYLE="inset"></ASP:BUTTON>
Public Sub btnPopulateAllCommunities_OnClick(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles btnAllCommunities.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="GetReport1_OnClick" RUNAT="server" TEXT="Get
report of" HEIGHT="20"
FONT-SIZE="10px"></ASP:BUTTON>
Sub GetReport1_OnClick(ByVal Sender As Object, ByVal e As System.EventArgs)
Try
dgSHA.Visible = False
dgShasSum.Visible = False
dgCommunity.Visible = True
dgCommunitiesSum.Visible = True
ShowButtons()
'pnlCommunitiesButtons.Visible = True
Dim _sqlStmtR1 As String
_sqlStmtR1 = "SELECT * FROM vwCommunities WHERE countryID = '" &
CType(Page,
_default1).chooseAdminUnitsWiz1.lbCountriesWiz.SelectedItem.Value & "' "
If ddlImpactLevel1.SelectedItem.Value <> "All" Then
_sqlStmtR1 = _sqlStmtR1 & " AND Impact = '" &
ddlImpactLevel1.SelectedItem.Value & "'"
End If
'_sqlStmtR1 = _sqlStmtR1 & " ORDER BY Community"
Dim myDataSetCommunities1 As New DataSet
Dim myDataAdapterCommunities1 As New SqlDataAdapter(_sqlStmtR1,
connection1.conString)
myDataAdapterCommunities1.Fill(myDataSetCommunities1,
"CommunitiesTmp1")
dgCommunity.DataSource =
myDataSetCommunities1.Tables("CommunitiesTmp1")
dgCommunity.DataBind()
CommunitiesWizSqlSumStatement(1)
Dim myDataSetCommunitiesSum As New DataSet
Dim myDataAdapterCommunitiesSum As New
SqlDataAdapter(_sqlStmtLbCommunitiesWizSum, connection1.conString)
myDataAdapterCommunitiesSum.Fill(myDataSetCommunitiesSum,
"CommunitiesSumTmp1")
dgCommunitiesSum.DataSource =
myDataSetCommunitiesSum.Tables("CommunitiesSumTmp1")
dgCommunitiesSum.DataBind()
RecordCount2.Text = ""
RecordCount3.Text = ""
RecordCount4.Text = ""
RecordCount5.Text = ""
RecordCount6.Text = ""
Dim RcdCount As Integer
Dim ResultCount As Integer
RcdCount =
myDataSetCommunities1.Tables("CommunitiesTmp1").Rows.Count.ToString()
ResultCount = RcdCount
RecordCount1.Text = RcdCount & " records"
RecordCountBottom.Text = RcdCount & " records"
Session("savedDataGridSql") = _sqlStmtR1
Session("dgType") = "Community"
Me.sortCriteria = "Community"
Me.sortDir = "ASC"
If Session("dgType") = "Community" Then
pnlCommunitiesButtons.Visible = True
pnlShasButtons.Visible = False
Else
pnlCommunitiesButtons.Visible = False
pnlShasButtons.Visible = True
End If
Catch ex As Exception
ExceptionManager.Publish(ex)
End Try
End Sub