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

Binding the dropdown in grid by user defined function

5 Answers 115 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Pushkar
Top achievements
Rank 2
Pushkar asked on 31 Jan 2009, 06:30 AM
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>

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 02 Feb 2009, 05:40 AM
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


0
Pushkar
Top achievements
Rank 2
answered on 02 Feb 2009, 02:47 PM
Thansk shinu.. but I want to pass datasouce from server side code.
0
Justin
Top achievements
Rank 1
answered on 03 Feb 2009, 06:56 PM
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();  
 
        }  
 
    }  

 

 

 

0
Pushkar
Top achievements
Rank 2
answered on 04 Feb 2009, 04:07 AM
Thanks Justin.  It is working
0
Bricton Perez
Top achievements
Rank 1
answered on 03 May 2010, 07:34 PM
Pushkar !!!  Could you tell me How you made it work?

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



Tags
Grid
Asked by
Pushkar
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Pushkar
Top achievements
Rank 2
Justin
Top achievements
Rank 1
Bricton Perez
Top achievements
Rank 1
Share this question
or