Binding the dropdown in grid by user defined function

6 posts, 0 answers
  1. Pushkar
    Pushkar avatar
    8 posts
    Member since:
    Jan 2009

    Posted 31 Jan 2009 Link to this post

    Hello
    I have used dropdown column in my rad grid. I am trying to bind it with a method (DataSourceID='<%# LoadPolicyType()). but I got the error "Telerik.Web.UI.GridDropDownColumn does not have a DataBinding event". Please suggest me how can I bind the dropdown with my sub-routine. 

    aspx Code Sample:
    <telerik:GridDropDownColumn DataField="PolicyType" DataSourceID='<%# LoadPolicyType() %>'
                            HeaderText="Policy Type" ListTextField="PolicyType" ListValueField="PolicyTypeID"
                            UniqueName="PolicyType" >
                </telerik:GridDropDownColumn>

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

    Posted 01 Feb 2009 Link to this post

    Hi Pushkar,

    DataSourceID represents the ID(string ) of the DataSource control which will be used to populate the DropDown with data. You can set the DataSourceID for the GridDropDownColumn as shown below.

    ASPX:
    <telerik:GridDropDownColumn    HeaderText="DropCol"  UniqueName="DropCol" DataSourceID="SqlDataSource1"  ListTextField="ProductName" ListValueField="ProductName"  DataField="ProductName"  ></telerik:GridDropDownColumn> 

     <asp:SqlDataSource ID="SqlDataSource1" runat="server"   ConnectionString="<%$ ConnectionStrings:NorthWindConnectionString %>" 
                    SelectCommand="SELECT [ProductID], [ProductName], [SupplierID] FROM [Products]" > 
                </asp:SqlDataSource> 

    Customize/Configure GridDropDownColumn

    Shinu


  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Pushkar
    Pushkar avatar
    8 posts
    Member since:
    Jan 2009

    Posted 02 Feb 2009 Link to this post

    Thansk shinu.. but I want to pass datasouce from server side code.
  5. Justin
    Justin avatar
    35 posts
    Member since:
    Apr 2008

    Posted 03 Feb 2009 Link to this post

    Pushkar - if I understand what you are wanting to do correctly, and functionality of grid, you could try setting something like the following in code behind:

     

     

    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
        {  
            if (e.Item is GridEditableItem && (e.Item as GridEditableItem).IsInEditMode)  
            {  
                GridEditableItem eeditedItem = e.Item as GridEditableItem;  
                GridEditManager editMan = editedItem.EditManager;  
     
                GridDropDownListColumnEditor editor = editMan.GetColumnEditor("PolicyType") as GridDropDownListColumnEditor;  
                editor.DataSource = LoadPolicyType();  
                editor.DataBind();  
     
            }  
     
        }  

     

     

     

  6. Pushkar
    Pushkar avatar
    8 posts
    Member since:
    Jan 2009

    Posted 03 Feb 2009 Link to this post

    Thanks Justin.  It is working
  7. Bricton Perez
    Bricton Perez avatar
    12 posts
    Member since:
    Aug 2009

    Posted 03 May 2010 Link to this post

    Pushkar !!!  Could you tell me How you made it work?

    I have something like this DataSourceID='<%# GetEmployee() %>' I appreciate your help



Back to Top
UI for ASP.NET Ajax is Ready for VS 2017