How to insert blank item in Telerik OpenAccessLinqDataSource programmatically?

Thread is closed for posting
2 posts, 0 answers
  1. Prasad
    Prasad avatar
    1 posts
    Member since:
    Jan 2012

    Posted 30 Jun 2014 Link to this post

    I am using Telerik OpenAccessLinqDataSource. I have loaded the records into that and assign its id to dropdownlist. Its working fine. But, now I want to add blank item into it. How can I insert blank item to Telerik OpenAccessLinqDataSource programmatically and pass it to dropdownlist?
  2. Doroteya
    Doroteya avatar
    498 posts

    Posted 02 Jul 2014 Link to this post

    Hi Prasad,

    To achieve the necessary behavior you  can use the DataBound event of RadDropDownList and in it to add a blank item without inserting it to the datasource at all. For example:

    <telerik:RadDropDownList runat="server" ID="rDropDownList"
        DataSourceID="oaLinqDataSource" DataTextField="PropertyToDisplay" DataValueField="IDProperty"
        DropDownHeight="200" EnableVirtualScrolling="true"
    protected void rDropDownList_DataBound(object sender, EventArgs e)
        this.rDropDownList.Items.Insert(0, new Telerik.Web.UI.DropDownListItem());
        this.rDropDownList.SelectedIndex = 0;

    This way after you retrieve the records through the datasource and bind the result to the control, at the top of the list you will have a blank item.

    I hope this helps. If you have additional questions, do not hesitate to get back to us.

    OpenAccess ORM is now Telerik Data Access. For more information on the new names, please, check out the Telerik Product Map.
Back to Top