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

Reference to Control in a RadGrid CommandItemTemplate

1 Answer 198 Views
Integration with other products
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andrew
Top achievements
Rank 1
Andrew asked on 05 Oct 2010, 04:58 PM
Hi,

The <WhereParameters > of an OpenAccessDataSource can include an <asp:ControlParameter ControlID="xxx" Propertyname="yyy" Name="zzz" and so on />

This can reference a Control which is located on the page, but it does not appear to be able to refer to a control which is located within the CommandItemTemplate of a RadGrid.

Further I would like to use a "UserControl ascx" to contain the various controls which I want to appear in the CommandItemTemplate - at the moment I can't get it to work when the Control is directly within the CommandItemTemplate or within a user control within it.


Basically I have a RadGrid linked through an OpenAccessDataSource to display data from the database, and I want to apply more sophisticated filtering than is possible using the built-in filter facilities of the grid (e.g. selection of multiple items from a drop down combo).

I would like these "filter controls" to be inside the command item of the grid (so that they take up one row of my limited screen real estate i.e. they are on the same line as the refresh and other grid command buttons). But when I move the control inside the Command Item it is no longer "visible" to the Control Parameter.

And as mentioned above, in fact I really need a "multi-select" Combo, which I have successfully created within a UserControl (ascx) (so that I dont' have to keep repeating the code to handle multi-selects) and which I can refer to when the User Control is outside the Command Item, but not when it is within - but one step at a time.

1 Answer, 1 is accepted

Sort by
0
Damyan Bogoev
Telerik team
answered on 08 Oct 2010, 04:36 PM
Hello Andrew,

I suggest you to initialize the OpenAccessDataSource’s control parameters within the RadGrid.ItemCreated event handler and set the ControlID to the control’s UniqueID:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridCommandItem)
    {
        GridCommandItem commandItem = e.Item as GridCommandItem;
        LinkButton button = commandItem.FindControl("LinkButton1") as LinkButton;
        if (button != null)
        {
            ControlParameter parameter = new ControlParameter("LinkButton1", button.UniqueID, "CommandName");
            this.OpenAccessDataSource1.WhereParameters.Add(parameter);
        }
    }
}

Hope that helps.

All the best,
Damyan Bogoev
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
Tags
Integration with other products
Asked by
Andrew
Top achievements
Rank 1
Answers by
Damyan Bogoev
Telerik team
Share this question
or