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


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

       thanks
       Savyo
  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.

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top