The drop down list is populated with values, but when they are selected nothing happens to the table.
I am trying to iterate through the column, get the distinct values and add them to a filter.
It works when i Add a new asp:SqlDataSource with a distinct sql statement, then add datasourceID, datavalue and datatext to the ComboBox, but need to get this working programmatically.
Column:
<telerik:GridBoundColumn DataField="OperationalTypeName" HeaderText="OperationalTypeName" SortExpression="OperationalTypeName">
<FilterTemplate>
<telerik:RadComboBox ID="operationtypeComboBox" runat="server" RenderMode="Lightweight"
SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("OperationalTypeName").CurrentFilterValue %>'
OnClientSelectedIndexChanged="OpertationalTypeIndexChanged">
</telerik:RadComboBox>
<telerik:RadScriptBlock runat="server">
<script type="text/javascript">
function OpertationalTypeIndexChanged(sender, args) {
var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
tableView.filter("OperationalTypeName", args.get_item().get_value();, "EqualTo");
}
</script>
</telerik:RadScriptBlock>
</FilterTemplate>
</telerik:GridBoundColumn>
ItemDataBound:
protected void GridView1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridFilteringItem)
{
GridFilteringItem item = (GridFilteringItem)e.Item;
RadComboBox combo = (RadComboBox)item.FindControl("operationtypeComboBox");
//combo.Items.Add(new RadComboBoxItem("ALL"));
foreach (var filter in filterOperationalType())
//filterOperatiionType returns the correct list
{
combo.Items.Add(new RadComboBoxItem(filter, filter));
// they are added to the ComboBox but do not work, the html generated is exactly the same as the filter options that work through using DataSourceID used on the ComboBox.
}
}
}
private List<string> filterOperationalType()
{
DataView view = (DataView)this.SqlDataSource1.Select(DataSourceSelectArguments.Empty);
List<string> list = new List<string>();
foreach (DataRow item in view.Table.Rows)
{
list.Add(item.ItemArray[1].ToString());
}
var a = list.Distinct().ToList();
return a;
}
Thank you