2) Questions ... which might as well have some other filters acting as Foreign Keys
3) AnswersToQuestions
If I filter (2) Questions by (1) TypeOfQuestions and all other filters that might have been chosen by the end-user, then, somehow, I think I could use that data and the query with all its filtering (don't even know how) as DataSource for feeding the (3)
Questions table so I can save each questions plus its answer in table number (2)
I understand that you are filtering a GridView or some Data Control with some filter options like TypeOfQuestions, etc. and you require to further use the filtered resulting Data. If this is correct then I would suggest to save the filter conditions in Session
or (preferably) save the filtered resulting data to session to use.
नमस्ते,
[KaushaL] BlogTwitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
How do you filter and bind your GridView right now? You might be using List or DataTable/DataSet of some other kind of DataSource? You just need to save that data source in a session variable. This way you will be able to get the filtered result data directly.
And if you wish to get the query for this data, then I would suggest to store the filter criteria in session variable to be used in further, when required. You may post your affecting code, if you need further assistance.
नमस्ते,
[KaushaL] BlogTwitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
From your description. it is hard for us to provide you with a specific solution for you.
Would you please provide us with related code you have done at present and with the description of your next step.
So that we could get what is your problem. and provide you with some code for you.
Best regards
Cathy
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
The purpose of QueryableFilterRepeater is to generate set of filters for a set of columns. It should contain DynamicFilter control
which is the actual placeholder for a FilterTemplate control. QueryableFilterRepeater implements IFilterExpressionProvider interface that is supported by QueryExtender via DynamicFilterExpression control.
using System;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.DynamicData;
using System.Web.Routing;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.Expressions;
namespace WebApplication4
{
public partial class List : System.Web.UI.Page
{
protected MetaTable table;
protected void Page_Init(object sender, EventArgs e)
{
table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
GridView1.SetMetaTable(table, table.GetColumnValuesFromRoute(Context));
GridDataSource.EntityTypeFilter = table.EntityType.Name;
}
protected void Page_Load(object sender, EventArgs e)
{
Title = table.DisplayName;
GridDataSource.Include = table.ForeignKeyColumnsNames;
// Disable various options if the table is readonly
if (table.IsReadOnly)
{
GridView1.Columns[0].Visible = false;
InsertHyperLink.Visible = false;
GridView1.EnablePersistedSelection = false;
}
}
protected void Label_PreRender(object sender, EventArgs e)
{
Label label = (Label)sender;
DynamicFilter dynamicFilter = (DynamicFilter)label.FindControl("DynamicFilter");
QueryableFilterUserControl fuc = dynamicFilter.FilterTemplate as QueryableFilterUserControl;
if (fuc != null && fuc.FilterControl != null)
{
label.AssociatedControlID = fuc.FilterControl.GetUniqueIDRelativeTo(label);
}
}
protected override void OnPreRenderComplete(EventArgs e)
{
RouteValueDictionary routeValues = new RouteValueDictionary(GridView1.GetDefaultValues());
InsertHyperLink.NavigateUrl = table.GetActionPath(PageAction.Insert, routeValues);
base.OnPreRenderComplete(e);
}
protected void DynamicFilter_FilterChanged(object sender, EventArgs e)
{
GridView1.PageIndex = 0;
}
}
}
I am just respectful saying what I know about ASP.Net Dynamic Data
So filtering works like this
So I add this 2 pictures in order to let you know what ASP.Net Dynamic Data is about. So in its simplest way, it doesn't really manages postback, state, ...and traditional ASP.Net Web Forms stuff
It works quite different because it works based on templates. You only have 4 pages: List, Edit, Insert and Details and a ListDetails alternative one
Maybe quite overwhelming, isn't it?
But there are people in the dynamic data team, as Mr. Eboo, that clearly know this well.
I was hoping maybe one of you might request him an answer to this
What I'd like to accomplish is this: having a filtered datasource which will be used in a gridview to displaying some data, then I'd like to have such LINQ sentence or SQL query so I can build on the fly a new datasource (using a diferent table than the
one used in the gridview from which I extracted the LINQ) as to accomplish that the saving process goes directly into another table which will be defined in the new datasource ...
I'm no expert, I just started SQL Profiler up and then stopped it once the query I wanted to capture had been run then I went through each entry until I found the actual query I wanted :)
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Member
6 Points
43 Posts
Capturing the SQL used by a GridView
Mar 31, 2017 10:29 PM|CPorras|LINK
Let's say I have 3 tables.
1) TypeOfQuestions
2) Questions ... which might as well have some other filters acting as Foreign Keys
3) AnswersToQuestions
If I filter (2) Questions by (1) TypeOfQuestions and all other filters that might have been chosen by the end-user, then, somehow, I think I could use that data and the query with all its filtering (don't even know how) as DataSource for feeding the (3) Questions table so I can save each questions plus its answer in table number (2)
Is that doable?
All-Star
31362 Points
7055 Posts
Re: Capturing the SQL used by a GridView
Apr 02, 2017 08:30 AM|kaushalparik27|LINK
I understand that you are filtering a GridView or some Data Control with some filter options like TypeOfQuestions, etc. and you require to further use the filtered resulting Data. If this is correct then I would suggest to save the filter conditions in Session or (preferably) save the filtered resulting data to session to use.
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
Member
6 Points
43 Posts
Re: Capturing the SQL used by a GridView
Apr 02, 2017 12:58 PM|CPorras|LINK
Thanks for your answer. It might be very, very helpful, if I knew how to do that? Is there a way which you might recommend?
All-Star
31362 Points
7055 Posts
Re: Capturing the SQL used by a GridView
Apr 02, 2017 01:35 PM|kaushalparik27|LINK
How do you filter and bind your GridView right now? You might be using List or DataTable/DataSet of some other kind of DataSource? You just need to save that data source in a session variable. This way you will be able to get the filtered result data directly. And if you wish to get the query for this data, then I would suggest to store the filter criteria in session variable to be used in further, when required. You may post your affecting code, if you need further assistance.
[KaushaL] Blog Twitter [MS MVP 2008 & 2009] [MCC 2011] [MVP Reconnect 2017]
Don't forget to click "Mark as Answer" on the post that helped you
None
0 Points
2 Posts
Re: Capturing the SQL used by a GridView
Apr 02, 2017 02:16 PM|cnporras|LINK
Star
8670 Points
2882 Posts
Re: Capturing the SQL used by a GridView
Apr 03, 2017 03:27 AM|Cathy Zou|LINK
Hi CPorras,
From your description. it is hard for us to provide you with a specific solution for you.
Would you please provide us with related code you have done at present and with the description of your next step.
So that we could get what is your problem. and provide you with some code for you.
Best regards
Cathy
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
6 Points
43 Posts
Re: Capturing the SQL used by a GridView
Apr 03, 2017 06:34 AM|CPorras|LINK
List page code is
The purpose of QueryableFilterRepeater is to generate set of filters for a set of columns. It should contain DynamicFilter control which is the actual placeholder for a FilterTemplate control. QueryableFilterRepeater implements IFilterExpressionProvider interface that is supported by QueryExtender via DynamicFilterExpression control.
I am just respectful saying what I know about ASP.Net Dynamic Data
So filtering works like this
So I add this 2 pictures in order to let you know what ASP.Net Dynamic Data is about. So in its simplest way, it doesn't really manages postback, state, ...and traditional ASP.Net Web Forms stuff
It works quite different because it works based on templates. You only have 4 pages: List, Edit, Insert and Details and a ListDetails alternative one
.
.
Member
6 Points
43 Posts
Re: Capturing the SQL used by a GridView
Apr 04, 2017 05:58 PM|CPorras|LINK
Maybe quite overwhelming, isn't it?
But there are people in the dynamic data team, as Mr. Eboo, that clearly know this well.
I was hoping maybe one of you might request him an answer to this
What I'd like to accomplish is this: having a filtered datasource which will be used in a gridview to displaying some data, then I'd like to have such LINQ sentence or SQL query so I can build on the fly a new datasource (using a diferent table than the one used in the gridview from which I extracted the LINQ) as to accomplish that the saving process goes directly into another table which will be defined in the new datasource ...
ERD
https://ibb.co/nnzYAa
Filtering Conditions
https://ibb.co/hsEN3v
GridView Source Table
https://ibb.co/jv3tAa
Entity in which I'd like to save the data
https://ibb.co/fLQ6Va
Sounds crazy but I thinks is doable and I just like to know:
AT WHICH POINT INSIDE SOME METHOD MAY I CAPTURE SUCH LINQ SENTENCE (OR SQL SENTENCE) so I could reach it via debugging and grab the wanted sentence
Having this, I could simulate the many-to-many improved control that currently seems not to be available anywhere else on the web
Member
6 Points
43 Posts
Re: Capturing the SQL used by a GridView
Apr 04, 2017 06:06 PM|CPorras|LINK
It should be better like this to do the filtering at once .. isn't it?
All-Star
17916 Points
5681 Posts
MVP
Re: Capturing the SQL used by a GridView
Apr 07, 2017 11:25 AM|sjnaughton|LINK
Hi Carlos, if you just need to see the query I usually use SQL Profiler to get the SQL DD the EF Data Source creates, it's very messy but it works.
Always seeking an elegant solution.
Member
6 Points
43 Posts
Re: Capturing the SQL used by a GridView
Apr 07, 2017 02:41 PM|CPorras|LINK
good steve, ... excellent !
I just need to know "where" ... at what step in the process may I reach such messy sentence
I'd be delighted if I knew that
Yo Are My Hero Steve !!!!!!!!!!!!!!!!!!!
All-Star
17916 Points
5681 Posts
MVP
Re: Capturing the SQL used by a GridView
Apr 07, 2017 03:13 PM|sjnaughton|LINK
I'm no expert, I just started SQL Profiler up and then stopped it once the query I wanted to capture had been run then I went through each entry until I found the actual query I wanted :)
Always seeking an elegant solution.