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

RadGrid Combox Filter

1 Answer 88 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 12 Mar 2011, 07:34 PM
Been looking at this for a while and just dont see what I am missing. I tried adding a ComboBox as a filter to a datagrid I am building but keep getting a syntax error near '.'. when the grid tries to rebind. I have looked over the code 100 times and cannot find any syntax error. Any help would be much appreciated.

<

 

 

telerik:RadComboBox ID="ComboSchedule" DataSourceID="SqlDataSource3" DataTextField="SCHED" DataValueField="SCHED" Height="200px" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("SCHED").CurrentFilterValue %>'

 

 

 

runat="server" OnClientSelectedIndexChanged="TitleIndexChanged" AppendDataBoundItems="true">

 

 

 

<Items>

 

 

 

<telerik:RadComboBoxItem Text="All" />

 

 

 

</Items>

 

 

 

</telerik:RadComboBox>

 

 

 

<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

 

 

 

<script type="text/javascript">

 

 

 

function TitleIndexChanged(sender, args) {

 

 

 

 

var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");

 

 

tableView.filter(

 

"SCHED", args.get_item().get_value(), "EqualTo");

 

 

}

 

 

 

</script>

 

 

 

 

</telerik:RadScriptBlock>

 


Then in the codebehind

Protected

 

 

Sub RadGrid1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid1.PreRender

 

 

 

 

If Not RadGrid1.MasterTableView.FilterExpression Is String.Empty Then

 

RefreshCombos()

 

 

End If

 

 

 

End Sub

 

 

 

Protected Sub RefreshCombos()

 

 

SqlDataSource3.SelectCommand = SqlDataSource3.SelectCommand &

 

" WHERE " & RadGrid1.MasterTableView.FilterExpression.ToString()

 

 

RadGrid1.MasterTableView.Rebind()

 

 

 

End Sub

 



Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 14 Mar 2011, 11:36 AM
Hi Chris,

Can you try setting the EnableLinqExpressions property of your RadGrid to false and see if it makes any difference?
Other than this, you can try debugging the RefreshCombos method and see if the SelectCommand is properly created, e.g. using proper SQL syntax.

Greetings,
Iana
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Tags
General Discussions
Asked by
Chris
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or