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

Set selected value in dropdown in grid header

1 Answer 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
L
Top achievements
Rank 1
L asked on 11 Sep 2013, 09:31 PM
Hi,

I have a radgrid that have a radcombobox in the header of one of the columns. I'm building the radcombobox in the OnItemCreated event. When  I select a value in the radcombobox, I filter the grid based on the selected value and store the selected value in the session. My problem is in the radgrid OnPreRender event, I'm trying to set the selected value of the radcombo box and it is not been set. the control is ajaxified, I can see through the debugger that is setting the correct selected item, but when the grid shows up, the value is not selected. Any ideas?

This is the code I'm using to set the selected item
protected void radGridUnits_OnPreRender(object sender, EventArgs e)
        {
                // Select the last selected value
                if (Session["filteredByPendingAction"] != null)
                    foreach (GridHeaderItem h in radGridUnits.MasterTableView.GetItems(GridItemType.Header))
                    {
                        ((RadComboBox)h["ExternalActions"].FindControl("radComboFilteredByPendingActions")).FindItemByValue(Session["filteredByPendingAction"].ToString()).Selected = true;
                        ((RadComboBox)h["ExternalActions"].FindControl("radComboFilteredByPendingActions")).DataBind();
                        break;
                    }
            }


Thanks in adavance

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 16 Sep 2013, 11:31 AM
Hi,

You can use the CurrentFilterValue of the column to preserve the selected combo value:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx#

Hope this helps.

Regards,
Eyup
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
L
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or