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

Programmatically adding data to a Filter Template

2 Answers 163 Views
Grid
This is a migrated thread and some comments may be shown as answers.
ColinBlakey
Top achievements
Rank 2
ColinBlakey asked on 13 Dec 2011, 04:22 PM
I'm adding a dropdown filter control as a usercontrol. Basically like the demo at http://demos.telerik.com/aspnet-ajax/grid/examples/programming/filtertemplate/defaultcs.aspx but take the RadComboBox and script and put them into a usercontrol. See code block

<telerik:GridHyperLinkColumn .... UniqueName="CustomerNumber" Groupable="False">
   <FilterTemplate>
      <vtx:GridFilter ID="CustNumFilter" Field="CustomerNumber" runat="server"/>
   </FilterTemplate>
</tlk:GridHyperLinkColumn>

I need to get access to the usercontrol programmatically to add the data to it but I cannot figure out how and where to do this.

Thanks

Colin Blakey

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Dec 2011, 05:29 AM
Hello,

Try the following code.
C#:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
  if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
   {
     UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
     RadGrid grid = (RadGrid)userControl.FindControl("RadGrid2");
     grid.ItemDataBound += new GridItemEventHandler(grid_ItemDataBound);
   }
}
void grid_ItemDataBound(object sender, GridItemEventArgs e)
{
  if (e.Item is GridFilteringItem)
  {
     GridFilteringItem fitem = (GridFilteringItem)e.Item;
     RadComboBox combo = (RadComboBox)fitem.FindControl("CustNumFilter");
      //populate the ComboBox
  }
}

-Shinu.
0
ColinBlakey
Top achievements
Rank 2
answered on 14 Dec 2011, 05:06 PM
Shinu,

That has got me going in the right direction.

Thank you
Tags
Grid
Asked by
ColinBlakey
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
ColinBlakey
Top achievements
Rank 2
Share this question
or