Last post Dec 19, 2008 11:22 AM by davidfowl
Dec 09, 2008 09:53 AM|SScannell|LINK
I've been using the 4.0 preview with a web application. I would like to add plain text searching. Ideally, I would add a textbox and a button below a FilterRepeater, and then code the LinqDataSource to automagically combine the FilterRepeater values with the
plain text. Or add code to the events in GridDataSource_Selecting or btnSearch_OnClick. But since I haven't been able to make those approaches work, and because there is no 4.0 sample showing FK with plain text search, maybe it's not possible.
I could use Josh's classes but I'm not sure if Josh's classes work with the new LinqDataSource. Also, I prefer the style of the FK drop down in 4.0. There was a filtering bug in 3.5 described here
http://forums.asp.net/p/1313772/2593318.aspx that made me move up to 4.0. Aside from all that, Josh's text search stuff is excellent.
If I have to dump the FilterRepeater, would I add drop downs with <asp:DropDownList? It seems like I would call <asp:ForeignKey, but there isn't one of those in the toolbox.
Filter dynamic data foreign key
Dec 09, 2008 12:10 PM|sjnaughton|LINK
I could use Josh's classes but I'm not sure if Josh's classes work with the new LinqDataSource
Also the new dataSources that come with 4.0 that allows search dont work with Dynamic Data yet [:(]
As for Josh's stuff I recommend downloading the source code which has a sample site with search implemented you will need SQL 2008 to run this though [:)]
Hope this helps [:D]
Dec 09, 2008 10:49 PM|SScannell|LINK
Thanks Steve, and nice work on your site.
Dec 10, 2008 04:05 AM|davidfowl|LINK
The new preview bits have a QueryBlock in the LinqDataSource and BusinessLogicDataSource that can be used to do advanced filtering. The new dynamic data filter architecture is built on top of this. If you take a look at the BusinessLogicDataSource sample,
there is an example on how to use the Search expression to add searching to your page.
Dec 10, 2008 06:37 AM|sjnaughton|LINK
Hi David is there a new preview out - soon? as I was told by either Rick anderson or Scott Hunter that the search does not work with DD yet?
Dec 10, 2008 11:56 AM|SScannell|LINK
Thanks David, I did find that sample. I couldn't get search to work with a FilterRepeater in the LinqDataSource although maybe it would with individual FilterUserControls. Also I suppose I could write event code on selecting or gridview prerender. But
I'm a VB guy and the samples are C#. The best option seems to be to wait for the next release.
Dec 10, 2008 12:43 PM|scothu|LINK
Stephen, we are going to try and get a new preview release up this week. :-) Watch this space.
Dec 10, 2008 02:42 PM|sjnaughton|LINK
Thanks Scott that's great news [:D]
Dec 19, 2008 10:06 AM|SScannell|LINK
I was able to combine search and a FilterRepeater with DD Preview 2. Thanks to the DD team for the V2 release.
My search block looks like this:
<asp:QueryableFilterRepeater runat="server" ID="FilterRepeater">
<asp:Label ID="Label1" runat="server" Text='<%# Eval("DisplayName") %>' />
<asp:DynamicFilter runat="server" ID="DynamicFilter" OnFilterChanged="DynamicFilter_FilterChanged" /><br />
<asp:TextBox ID="Search" Text="" runat="server"></asp:TextBox>
<asp:Button ID="btnRefresh" runat="server" Text="Search" /><br />
There is no code behind the button. Clicking it runs the search.
My QueryExtender block looks like this:
<aspX:QueryExtender TargetControlID="GridDataSource" ID="GridQueryExtender" runat="server">
<asp:DynamicFilterExpression ControlID="FilterRepeater" />
Name="Search" PropertyName="Text" Type="String" />
The SearchExpression tag requires s a DataFields property. You can hard code the search columns, or, to keep things dynamic, populate during page_load:
Dim searchexpression As Microsoft.Web.Data.UI.WebControls.Expressions.SearchExpression
searchexpression = GridQueryExtender.Expressions(1)
Dim col As System.Web.DynamicData.MetaColumn
For Each col In table.Columns
If col.ColumnType.Name = "String" And col.Scaffold Then
If Len(searchexpression.DataFields) Then
searchexpression.DataFields = searchexpression.DataFields & "," & col.Name
searchexpression.DataFields = col.Name
Dec 19, 2008 11:22 AM|davidfowl|LINK
Very cool [:D]