|
-
Jul 25th, 2002, 01:27 PM
#1
Thread Starter
New Member
DropDownList SelectedIndex not changing
I have a webform with a databound DropDownList on it. After selecting an entry from the list and submitting the form, the SelectedIndex property still contains the default value rather than the value that I selected from the list. I have other similary configured webforms with databound DropDownLists and they all work as expected. The only differences are that the form that doesn't work contains a UserControl and the pull their data from different tables. Any Ideas?
-
Jul 26th, 2002, 05:02 PM
#2
Lively Member
The first thing that comes to mind is the possibility of re-binding the control when your page is reloaded. Where are you binding the DropDownList? And are you verifying that property "Page.IsPostBack = False" before executing the code to bind the control?
Dr_Evil
Senior Programmer
VS6 EE
VS.NET EA
-
Nov 15th, 2002, 10:55 AM
#3
Hyperactive Member
I have the same problem.
I did the binding in control's properties window. can somebody tell how to make it work?
-
Nov 15th, 2002, 11:20 AM
#4
Hyperactive Member
hi,demtet,
can you tell how you made your other forms work? thanks.
-
Nov 15th, 2002, 03:15 PM
#5
Hyperactive Member
Only bind your data to the dropdownlist if Not page.ispostback=true. From then on the viewstate if the control will retain the list and it should highlight your chosen item.
i.e.
'Page Load event
If not page.ispostback then
BindData()
End If
Private Sub BindData
'code to bind data to dropdownlist
End Sub
-
Nov 15th, 2002, 03:24 PM
#6
Hyperactive Member
thanks.
another question:
How to populate date to datagrid programly? I want to fill the grid by a query result.
-
Nov 18th, 2002, 06:53 PM
#7
Addicted Member
VB Code:
Dim sql As String = "SELECT * FROM DPSlisting"
Dim ConnStr As String = "xxxxconn string xxxxx"
Dim mySQLconn As New SqlConnection(ConnStr)
mySQLconn.Open()
Dim mysqladapter As New SqlDataAdapter()
mysqladapter.SelectCommand = New SqlCommand(sql, mySQLconn)
Dim myDS As New DataSet()
mysqladapter.Fill(myDS)
mySQLconn.Close()
ddlListing.DataSource = myDS
ddlListing.DataTextField = ("ReportDate")
ddlListing.DataBind()
hope that helped?
Soylent Green tastes like chicken
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
|