Can this class be hooked to a sqldatasource in the main .aspx page ?
Or Any any idea how I would pass parameters to it so I can re-use the class ?
I have several different grids I want to add drop down filters to for "status" fields with limited choices and as this stands I would have to copy the class multiple times.
5 Answers, 1 is accepted
Please try the attached solution I've created for your convenience. I hope this helps!
Kind regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
A custom tag is registered and called
<%
@ Register TagPrefix="custom" Namespace="Filtering" Assembly="FilteringWithDDL" %>
But there is no class or dll called FilteringWithDDL
Parser Error Message: Could not load file or assembly 'FilteringWithDDL' or one of its dependencies. The system cannot find the file specified.
I do have this running with a custom tag and a seperate mycustomfiltering class now, but to load the data I have to create a datatable every time the page posts back. I am hoping your example uses a datasource on the .aspx page
Nikita
<custom:MyCustomFilteringColumn DataField="status" HeaderText="Status" UniqueName="TemplateColumn" SortExpression ="status">
<itemtemplate>
<%
#Eval("status")%>
</itemtemplate>
</custom:MyCustomFilteringColumn>
And since it is an over ride that adds properties, the only time it is referencedd is when it builds the .aspx page ,<custom:MyCustomFilteringColumn DataField="status" HeaderText="Status" UniqueName="TemplateColumn" SortExpression ="status">
<itemtemplate>
<%
#Eval("status")%>
</itemtemplate>
</custom:MyCustomFilteringColumn>
so I can not pass in parameters like a data source, or a variable control name.
Next version maybe they can cast filters as different controls and get a date range search back with the date picker :)
The most important item in the project I sent you was the Filtering.cs itself. You can easily put this file in App_Code when you create new web page.
The above mentioned code was intended to give you general directions and help you create your own class by adapting the existing one.
You can use the exposed property ListDataSource in order to bind your column with the desired data.
foreach (GridColumn column in RadGrid1.MasterTableView.RenderColumns) |
{ |
if (column is GridBoundColumnExtension) |
{ |
if (column.UniqueName == "CustomerIDList") |
{ |
DataTable dt = new DataTable(); |
dt.Columns.Add("CompanyName"); |
for (int i = 0; i < 5; i++) |
dt.Rows.Add("CompanyName" + i); |
(column as GridBoundColumnExtension).ListDataSource = dt; |
} |
} |
} |
If this example covers your expectations you may need to clean up the unnecessary code from the .cs file.
Regards,
Daniel
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.