I'm new to the dynamic data development concept and liked the idea of the fully customisable templates being generated for my projects.
However, one of the key conponents to my project will be displaying table contents in a search-edit form (i.e.users will be able to view the contents of a sql server table, filter & search the data in several ways & then add/edit/delete records from the
table).
I have looked at the dynamic data filtering and found quite a bit about implementing this in VS / VWD 2008 but the stuff i found on VS / VWD 2010 doesn't make any sense to me & seems way too complicated to be the only way to do this (i.e. creating custom
controls and then adding code behind to handle the filtering).
Why is the filtering aspect of dynamic data so complicated for such a fundemental feature?
Can someone give me a beginners guide into implementing custom filters into a dynamic data site?
stuff i found on VS / VWD 2010 doesn't make any sense to me & seems way too complicated to be the only way to do this
Filtering in DD4 is much simpler to extend than in DD1 the real power come from the QueryExtender, it allows very complex searches, for instance say you have 3 or 4 text fields you want to search on on a table all you do is add a textbox to the page and
add a SearchExpression to the pages QueryExtender
the AddCustomFilterValueToSession is not recognised (neither is the MULTI_COLUMN_SEARCH). Am i using the wrong version of something here?
Also, how would this work if i had multiple unrelated tables in my data context? If i define a textbox filter in my list template than it will work for one table but when i access the another table i will get an error. is it possible to get this working
for seperate tables with different field names?
Sorry Dabooj80, I meant to delete that line but it got lost in the code view [:$] it's variant of my article
Filter History for Dynamic Data 4 to add fileters history to the page. Just delete the else statement and line causing the issue.
Dynamic Data 4
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
Also, how would this work if i had multiple unrelated tables in my data context? If i define a textbox filter in my list template then it will work for one table but when i access the another table i will get an error. is it possible to get this working
for seperate tables with different field names without having to create my own seperate template pages?
It would seem that having to write partial classes & create individual template pages for each table you are going to use in order to get different filters working defeats the purpose of the dynamic data concept. If you are writing the classes & creating
the pages just to cater for filtering then the automated scaffolding created by dynamic data is kind of pointless unless you use one table.
Is there a way to use different filters within the same template for different tables?
Also, how would this work if i had multiple unrelated tables in my data context? If i define a textbox filter in my list template then it will work for one table but when i access the another table i will get an error. is it possible to get this working
for seperate tables with different field names without having to create my own seperate template pages?
Yes you could build the SearchExpression in code for each table adding an attribute that tells the your page which field to search on.
dabooj80
Is there a way to use different filters within the same template for different tables?
That is the default, filters (those that appear on the top of the page) are generic they work with column types not particulat columns of course you can always create custom filter sonly work for a particular table, but that is the exception.
The general rule is if you just need to tweek things for a couple of table I use CustomPages but when I find that I am adding the same sort of thing to many page I make it generic and work on the standard templtes driven by metadata.
filtersDynamic Data 4
See my blog C# Bits | Twitter @sjnaughton Always seeking an elegant solution.
From what you said, you don't need to create custom pages in order to get multiple search filters across multiple independant tables working with dynamic data. Is this correct?
If so, could you give me a quick example of how to use different filters for different tables using the serachExpression coding method that you mentioned?
I am trying to test dynamic data to see if it is suitable for developing rapid CRUD asp.net pages for multiple independant tables but the only stumbling block seems to be the filters issue so if you could enlighten me regarding this area then i would be
extremely grateful.
From what you said, you don't need to create custom pages in order to get multiple search filters across multiple independant tables working with dynamic data. Is this correct?
I am trying to test dynamic data to see if it is suitable for developing rapid CRUD asp.net pages for multiple independant tables but the only stumbling block seems to be the filters issue so if you could enlighten me regarding this area then i would be extremely grateful.
dabooj80
Member
3 Points
23 Posts
Custom filters & searches within DD in Visual Web Developer 2010
Jan 07, 2011 09:56 AM|LINK
Hi Guys,
I'm new to the dynamic data development concept and liked the idea of the fully customisable templates being generated for my projects.
However, one of the key conponents to my project will be displaying table contents in a search-edit form (i.e.users will be able to view the contents of a sql server table, filter & search the data in several ways & then add/edit/delete records from the table).
I have looked at the dynamic data filtering and found quite a bit about implementing this in VS / VWD 2008 but the stuff i found on VS / VWD 2010 doesn't make any sense to me & seems way too complicated to be the only way to do this (i.e. creating custom controls and then adding code behind to handle the filtering).
Why is the filtering aspect of dynamic data so complicated for such a fundemental feature?
Can someone give me a beginners guide into implementing custom filters into a dynamic data site?
Regards,
Shuja
sjnaughton
All-Star
25698 Points
5169 Posts
MVP
Re: Custom filters & searches within DD in Visual Web Developer 2010
Jan 07, 2011 12:50 PM|LINK
Filtering in DD4 is much simpler to extend than in DD1 the real power come from the QueryExtender, it allows very complex searches, for instance say you have 3 or 4 text fields you want to search on on a table all you do is add a textbox to the page and add a SearchExpression to the pages QueryExtender
<asp:TextBox ID="txbMultiColumnSearch" CssClass="DDTextBox" runat="server" /> <asp:Button ID="btnMultiColumnSearchSubmit" CssClass="DDButton" runat="server" Text="Search" onclick="btnMultiColumnSearch_Click" /> <asp:Button ID="btnMultiColumnSearchClear" CssClass="DDButton" runat="server" Text="Clear" OnClick="btnMultiColumnSearch_Click" />Then add some buttons, one to cause postback and the other to clear the textbox.
protected void btnMultiColumnSearch_Click(object sender, EventArgs e) { var button = (Button)sender; if (button.ID == btnMultiColumnSearchClear.ID) txbMultiColumnSearch.Text = String.Empty; }Then add the search expression to the QueryExtender,
<asp:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server"> <asp:DynamicFilterExpression ControlID="FilterRepeater" /> <asp:SearchExpression DataFields="Filed1,Field2,Field3.Table2.FieldName" SearchType="Contains" > <asp:ControlParameter ControlID="txbMultiColumnSearch" /> </asp:SearchExpression> </asp:QueryExtender>Hope that helps
Always seeking an elegant solution.
dabooj80
Member
3 Points
23 Posts
Re: Custom filters & searches within DD in Visual Web Developer 2010
Jan 07, 2011 01:18 PM|LINK
Hi sjnaughton,
I've tried using your code but i get an error with the line:
Page.AddCustomFilterValueToSession(table, MULTI_COLUMN_SEARCH, txbMultiColumnSearch.Text);
the AddCustomFilterValueToSession is not recognised (neither is the MULTI_COLUMN_SEARCH). Am i using the wrong version of something here?
Also, how would this work if i had multiple unrelated tables in my data context? If i define a textbox filter in my list template than it will work for one table but when i access the another table i will get an error. is it possible to get this working for seperate tables with different field names?
regards,
Shuja
sjnaughton
All-Star
25698 Points
5169 Posts
MVP
Re: Custom filters & searches within DD in Visual Web Developer 2010
Jan 07, 2011 03:48 PM|LINK
Sorry Dabooj80, I meant to delete that line but it got lost in the code view [:$] it's variant of my article Filter History for Dynamic Data 4 to add fileters history to the page. Just delete the else statement and line causing the issue.
Dynamic Data 4
Always seeking an elegant solution.
dabooj80
Member
3 Points
23 Posts
Re: Custom filters & searches within DD in Visual Web Developer 2010
Jan 07, 2011 04:06 PM|LINK
Ok, thanks.
Also, how would this work if i had multiple unrelated tables in my data context? If i define a textbox filter in my list template then it will work for one table but when i access the another table i will get an error. is it possible to get this working for seperate tables with different field names without having to create my own seperate template pages?
It would seem that having to write partial classes & create individual template pages for each table you are going to use in order to get different filters working defeats the purpose of the dynamic data concept. If you are writing the classes & creating the pages just to cater for filtering then the automated scaffolding created by dynamic data is kind of pointless unless you use one table.
Is there a way to use different filters within the same template for different tables?
Regards, Shuja
sjnaughton
All-Star
25698 Points
5169 Posts
MVP
Re: Custom filters & searches within DD in Visual Web Developer 2010
Jan 07, 2011 08:15 PM|LINK
Yes you could build the SearchExpression in code for each table adding an attribute that tells the your page which field to search on.
That is the default, filters (those that appear on the top of the page) are generic they work with column types not particulat columns of course you can always create custom filter sonly work for a particular table, but that is the exception.
The general rule is if you just need to tweek things for a couple of table I use CustomPages but when I find that I am adding the same sort of thing to many page I make it generic and work on the standard templtes driven by metadata.
filters Dynamic Data 4
Always seeking an elegant solution.
dabooj80
Member
3 Points
23 Posts
Re: Custom filters & searches within DD in Visual Web Developer 2010
Jan 10, 2011 02:53 PM|LINK
sjnaughton - thanks for your response.
From what you said, you don't need to create custom pages in order to get multiple search filters across multiple independant tables working with dynamic data. Is this correct?
If so, could you give me a quick example of how to use different filters for different tables using the serachExpression coding method that you mentioned?
I am trying to test dynamic data to see if it is suitable for developing rapid CRUD asp.net pages for multiple independant tables but the only stumbling block seems to be the filters issue so if you could enlighten me regarding this area then i would be extremely grateful.
Regards, Shuja
sjnaughton
All-Star
25698 Points
5169 Posts
MVP
Re: Custom filters & searches within DD in Visual Web Developer 2010
Jan 12, 2011 11:13 PM|LINK
Hi Shuja,
Yes this is correct see my article Adding a Multi-Column Search to the Default List page in Dynamic DataSee my article here Five Cool Filters for Dynamic Data 4 and it's also worth looking at Oleg Sych's articles here;
Filtering is very flexible and powerfull once you get into it [:)]
filters Dynamic Data 4 Query Extenders Multi Column Search
Always seeking an elegant solution.
klca
Member
453 Points
263 Posts
Re: Custom filters & searches within DD in Visual Web Developer 2010
Jan 14, 2011 01:45 AM|LINK
Check this out too
http://www.olegsych.com/
Carlos Porras (El Salvador)