combobox item selected

2 posts, 0 answers
  1. Savyo
    Savyo avatar
    75 posts
    Member since:
    Apr 2012

    Posted 07 Oct 2013 Link to this post

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

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 07 Oct 2013 Link to this post

    Hi Savyo,

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

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

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

Back to Top