Link to home
Start Free TrialLog in
Avatar of Lalla Belle
Lalla Belle

asked on

Hoe to set a default value for my populated dropwownlist


How can I set the default value for my populated dropdownlist from my dataset.

I populate my dropdownlist from my dataset, and then I need to set the default value to "South Africa"

            DropDownList_Country.DataSource = outputDS.Tables(0)
            DropDownList_Country.DataTextField = outputDS.Tables(0).Columns("country_name").ColumnName.ToString()
            DropDownList_Country.DataValueField = outputDS.Tables(0).Columns("country_code").ColumnName.ToString()

            For i = 0 To DropDownList_Country.Items.Count - 1
                If ComboWanted Then
                    DropDownList_Country.Items(i).Attributes.Add(i, outputDS.Tables(0).Rows(i).ToString())

                End If

            'we need to set the default to sa

How can I set the value to "South Africa" after it is populated?

Thank you
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial