Common DropDownList Issue
A common DropDownList issue I've seen on many forums and lists is about a DropDownList populating items 2x or not being able to get the selected value on postback when binding to a data source. This is due to the DropDownList having data bound to it again on postback before the form is processed. To prevent this, you will need to ensure that the DropDownList is only bound to data on the initial load of the page.
VB.NET
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
If Not IsPostBack Then
' Code here to bind data to DropDownList
End If
End Sub
C#
private void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Code here to bind data to DropDownList
}
}
R
Similar Posts
- Getting the content of a GridView cell on edit
- VB.NET GridView Sorting/Paging w/o a DataSourceControl DataSource
- C# GridView Sorting/Paging w/o a DataSourceControl DataSource





Comments
Peter Brunone on on 12.17.2005 at 11:33 PM
It's stuff like this that got me working on ELB in the first place :)