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

Dropdowncolumn with serverside radcombobox

1 Answer 68 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
BOS asked on 14 Apr 2010, 09:47 AM

I want to set the DataTextField of a RadComboBox at pageload according to the users prefered language - and keep that value.
So far my code looks like this:
(a small part of the mastertableview of the grid RadGridVehicle)

                <telerik:GridDropDownColumn DataSourceID="sdsHaulierType" 
                                            DataField="HaulierType" DataType="System.Int32" 
                                            HeaderText="Haulier type"   
                                            Visible="true" ForceExtractValue="Always" >  
                        <telerik:RadComboBox ID="cbHaulierType" runat="server"   
                                             DataSourceID = "sdsHaulierType" 
                                             DataValueField = "HaulierTypeID" 
                                             DataTextField = "HaulierTypeName" 
                                             SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("HaulierType").CurrentFilterValue %>'  
                                <telerik:RadComboBoxItem Text="All" />  
                        <telerik:RadScriptBlock ID="sbHaulierType" runat="server">  
                           <script type="text/javascript">  
                                function HaulierTypeChanged(sender,args)   
                                    var tableView=$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");  

I'm using a table called HaulierType with the following columns:
  • HaulierTypeID (PK)
  • HaulierTypeName (default column for DataTextField in the RadComboBox)
  • SVHaulierType
  • DAHaulierType
    <asp:SqlDataSource ID="sdsHaulierType" runat="server"   
                       ConnectionString="<%$ ConnectionStrings:MyConnectionString %>"   
                       SelectCommand="SELECT * FROM [HaulierType]">  

I can get the grid to show the correct values like this:
protected void RadGridVehicle_Load(object sender, EventArgs e)  
        ddc = (GridDropDownColumn)RadGridVehicle.MasterTableView.Columns.FindByUniqueName("HaulierType");  
        if (userLang == "da")  
            ddc.ListTextField = "DAHaulierType";  
        else if (userLang == "sv")  
            ddc.ListTextField = "SVHaulierType";  

What's missing is setting the filtervalues in the gridcolumn.
How do I set the DataTextField serverside and in which event?

Please help - I'm totally stock.

1 Answer, 1 is accepted

Sort by
Iana Tsolova
Telerik team
answered on 14 Apr 2010, 03:57 PM

You can handle the ItemCreated event of RadGrid and there find the desired RadComboBox, as shown below for instance:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    if (e.Item is GridFilteringItem)
        GridFilteringItem item = e.Item as GridFilteringItem;
        RadComboBox filterCombo = item["HaulierType"].FindControl("sbHaulierType") as RadComboBox;

For more information on how to access RadGrid cells and rows, you can refer to the below articles:

Sincerely yours,
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Asked by
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question