Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim var1 As String
var1 = DropDownList1.SelectedValue
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim var1 As String
var1 = "News" ' a value from the database
DropDownList1.SelectedValue = var1
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim var1 As String
var1 = "News" ' a value from the database
DropDownList1.DataBind() ' bind the dropwdownlist to the database and get it filled
DropDownList1.SelectedValue = var1
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim var1 As String
var1 = "News" ' a value from the database
DropDownList1.DataBind()
DropDownList1.SelectedIndex = DropDownList1.Items.IndexOf(DropDownList1.Items.FindByValue(var1.ToString.ToLower.Trim))
End Sub
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="Value" DataValueField="ID">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:testdbConnectionString %>"
SelectCommand="SELECT rtrim(ltrim(lower([Value]))), [Title] FROM [MyItems]"></asp:SqlDataSource>
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)