Hi
Can somebody explain for me how the FilterExpression works?
Im trying to get a simple example to work as I want it to do.
In the example I first used a FilterExpression on the SQLDataSource. First taken from a dropdownlist and then explicitly as "Login_Name='Patrik'". In both cases the filtering is working fine.
Then Im trying to do the same with the RadGrids MasterTableViews FilterExpression but it doesnt seem to work the same. Or Im not getting the syntax. How would I write the FilterExpression to do the same for me as in the SQLDataSource?
And secondly how could I get the FilterExpression to take the selection in the DropDownList?
//Mathias
Here is my code:
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml" > |
<head id="Head1" runat="server"> |
<title>ASP.NET Example</title> |
</head> |
<body> |
<form id="form1" runat="server"> |
<telerik:RadScriptManager runat="server"/> |
<asp:DropDownList |
id="DropDownList1" |
runat="server" |
AutoPostBack="True"> |
<asp:ListItem Selected="True">Roland</asp:ListItem> |
<asp:ListItem>Patrik</asp:ListItem> |
<asp:ListItem>Petter</asp:ListItem> |
</asp:DropDownList> |
<asp:SqlDataSource |
id="SqlDataSource1" |
runat="server" |
ConnectionString="???????" |
SelectCommand="SELECT * FROM Sys_Users"> |
<%-- FilterExpression="Login_Name='Patrik'"> |
<FilterParameters> |
<asp:ControlParameter Name="Title" ControlId="DropDownList1" PropertyName="SelectedValue"/> |
</FilterParameters> |
--%> </asp:SqlDataSource> |
<p><telerik:RadGrid |
id="GridView1" |
runat="server" |
DataSourceID="SqlDataSource1" |
AutoGenerateColumns="False"> |
<MasterTableView FilterExpression="([Login_Name]='Patrik')"> |
<Columns> |
<telerik:GridBoundColumn Visible="False" DataField="RecID" /> |
<telerik:GridBoundColumn HeaderText="First Name" DataField="F_Name" /> |
<telerik:GridBoundColumn HeaderText="Last Name" DataField="L_Name" /> |
<telerik:GridBoundColumn HeaderText="Login" DataField="Login_Name" /> |
</Columns> |
</MasterTableView> |
</telerik:RadGrid> |
</form> |
</body> |
</html> |