Empty String (1 Viewer)

accessman2

Registered User.
Local time
Today, 08:04
Joined
Sep 15, 2005
Messages
335
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

SqlDataAdapter1.Fill(DataSet11, "Months")
DropDownList1.DataSource() = DataSet11
DropDownList1.DataTextField = "Name"
DropDownList1.DataValueField = "Name"
DropDownList1.DataBind()

End Sub

When I load the ASP.NET in Visual Studio.NET, it will populate the first value on the dropdownlist. how can I add the empty string on the dropdownlist when the page is loaded.
 

dan-cat

Registered User.
Local time
Today, 15:04
Joined
Jun 2, 2002
Messages
3,433
Code:
SqlDataAdapter1.Fill(DataSet11, "Months")
DropDownList1.DataSource() = DataSet11
DropDownList1.DataTextField = "Name"
DropDownList1.DataValueField = "Name"
DropDownList1.DataBind()
 

DropDownList1.Items.Insert(0, New ListItem(String.Empty, String.Empty))

Totally untested, all I'm doing here is inserting a new listitem in the dropdownlist at the first (zero-index) position of the dropdown and the dropdownlist has been populated.
 

Users who are viewing this thread

Top Bottom