Marcio Nascimento
Top achievements
Rank 1
Marcio Nascimento
asked on 15 Aug 2009, 02:22 PM
Hello,
I'm having some difficulties in how to filter values without using the filtermenu.
For example:
First: I Bind RadGrid using SqlDataSource1.
Second: It is possible to filter a RadGrid programmatically by a value obtained by a SqlDataSource2 ?
Since now I thankyou for any help.
Marcio Nascimento
I'm having some difficulties in how to filter values without using the filtermenu.
For example:
First: I Bind RadGrid using SqlDataSource1.
Second: It is possible to filter a RadGrid programmatically by a value obtained by a SqlDataSource2 ?
Since now I thankyou for any help.
Marcio Nascimento
4 Answers, 1 is accepted
0
Marcio Nascimento
Top achievements
Rank 1
answered on 16 Aug 2009, 02:25 PM
Hi there,
I'm trying to use without success the code below to apply filter on initial load of an integer value:
It is possible to be an bug of RadGrid Filtering Options?
Marcio Nascimento
I'm trying to use without success the code below to apply filter on initial load of an integer value:
| protected void RadGrid1_PreRender(object sender, EventArgs e) |
| { |
| RadGrid1.MasterTableView.FilterExpression = "([id_case]) = 12"; |
| GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("id_case"); |
| column.CurrentFilterFunction = GridKnownFunction.EqualTo; |
| column.CurrentFilterValue = "12"; |
| RadGrid1.Rebind(); |
| } |
It is possible to be an bug of RadGrid Filtering Options?
Marcio Nascimento
0
Accepted
Mr. Plinko
Top achievements
Rank 1
answered on 17 Aug 2009, 05:09 PM
My first thought was that instead of doing it through the code, you could easily Configure Data Source 'Where' parameter of the SqlDataSource1 so that it equals 12 (or anything). That will provide the same result you are looking for without having to go through Telerik's filtering options. And because you can set the column value to a Control, Cookie, Form, Profile, QueryString or Session, there should be a ton of customizability.
I slapped together this where:
Column id_case = Control
ControlID = RadNumericTextBox1
Default Value = 12
But if you want to do this in code-behind, than this post is incredibly unhelpful... or is it?
I slapped together this where:
Column id_case = Control
ControlID = RadNumericTextBox1
Default Value = 12
| <asp:SqlDataSource ID="SqlDataSource1" runat="server" |
| ConnectionString="Data Source=computername\sqlexpress;Initial Catalog=thedatabasename;Integrated Security=True" |
| ProviderName="System.Data.SqlClient" |
| SelectCommand="SELECT * FROM [case] WHERE ([id_case] = @id_case)"> |
| <SelectParameters> |
| <asp:ControlParameter ControlID="RadNumericTextBox1" Name="id_case" DefaultValue="12" |
| PropertyName="Text" Type="Int32" /> |
| </SelectParameters> |
| </asp:SqlDataSource> |
| </div> |
| <telerik:RadNumericTextBox ID="RadNumericTextBox1" Runat="server"> |
| </telerik:RadNumericTextBox> |
| <asp:Button ID="Button1" runat="server" Text="Button" /> |
| </form> |
But if you want to do this in code-behind, than this post is incredibly unhelpful... or is it?
0
Marcio Nascimento
Top achievements
Rank 1
answered on 30 Aug 2009, 02:04 PM
Hello,
You just right and thanks for your code. It helps a lot.
But I've been thinking.....
Imagine a scenario that you need to filter a column that you don't know which will be.
I presume that telerik RadGrid provide a simple way to do this assuming that its filter capabilities are very powerful.
If somebody knows a simple way to filter RadGrids without using SqlDataSource I thank you so much.
Regards,
Marcio Nascimento
You just right and thanks for your code. It helps a lot.
But I've been thinking.....
Imagine a scenario that you need to filter a column that you don't know which will be.
I presume that telerik RadGrid provide a simple way to do this assuming that its filter capabilities are very powerful.
If somebody knows a simple way to filter RadGrids without using SqlDataSource I thank you so much.
Regards,
Marcio Nascimento
0
Mr. Plinko
Top achievements
Rank 1
answered on 31 Aug 2009, 02:58 PM
I found a link on applying default filter on initial load.
You can customize the code to include your second datasource.
The sample code is here:
Helpful?
You can customize the code to include your second datasource.
The sample code is here:
| protected void RadGrid1_PreRender(object sender, System.EventArgs e) |
| { |
| if (!Page.IsPostBack) |
| { |
| RadGrid1.MasterTableView.FilterExpression = "([Country] LIKE \'%Germany%\') "; |
| GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("Country"); |
| column.CurrentFilterFunction = GridKnownFunction.Contains; |
| column.CurrentFilterValue = "Germany"; |
| RadGrid1.MasterTableView.Rebind(); |
| } |
| } |
Helpful?