How do we get combo box's selected value in asp.net as we use to do in classic asp??

You can SelectedValue of Dropdownlist.

Dim str as String
str= DropDownlist1.SelectedValue

You can SelectedValue of Dropdownlist.

Dim str as String
str= DropDownlist1.SelectedValue

Hi,

Thanks for the reply but that gives the text not the key value,so i created a hash table and got the value pair like this,

If Not Page.IsPostBack Then
            get_data.execute_Sql("SELECT CCODE,COMPANY_NAME FROM COMPANY")

            While get_data.dr.Read
                arrData.Add(get_data.dr.Item(0), get_data.dr.Item(1))
            End While

            With cboCompany
                .DataSource = arrData
                .DataValueField = "key"
                .DataTextField = "value"
                .DataBind()
            End With
        End If

        MsgBox(cboCompany.SelectedValue)

Thanks for the reply...

Sabarish

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.