This is a migrated thread and some comments may be shown as answers.

combobox item selected

1 Answer 15 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Savyo
Top achievements
Rank 1
Savyo asked on 07 Oct 2013, 12:21 PM

      Hi,
          How shall I make the last item in combobox selected which is binded with sqldatasource.

   thanks
   Savyo

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 1
answered on 08 Oct 2013, 03:14 AM
Hi Savyo,

Please try the following code snippet that I tried to set the last item of RadComBox as selected.

ASPX:
<telerik:RadComboBox ID="RadComboBox1" runat="server" OnLoad="RadComboBox1_Load">
</telerik:RadComboBox>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT [id], [text] FROM [Details]">
</asp:SqlDataSource>

C#:
protected void RadComboBox1_Load(object sender, EventArgs e)
{
    RadComboBox1.DataTextField = "text";
    RadComboBox1.DataValueField = "id";
    RadComboBox1.DataSource = SqlDataSource1;
    RadComboBox1.DataBind();
    RadComboBox1.SelectedIndex = RadComboBox1.Items.Count - 1;
}

Thanks,
Shinu.
Tags
ComboBox
Asked by
Savyo
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 1
Share this question
or