FilterControlMode.MultiSelect not working

Oct 7, 2008 at 6:13 PM
This is a great tool, Josh; thanks very much - I'd love to know how you achieved the really good VS integration for the tools.

On to my problem.  I finally got everything all figured out, though it took me a little while, and mostly everything is working, but I need to give mey users the ability to get the rows in a table (~3000 rows total) where a particular column is *not* a given value (this table has mostly rows that match a given value, and they need to see the ones that *don't*).  MultiSelect seems the obvious filtering choice, but I can;t get it to work.  Everything compiles fine, but when I run the page I get the following:

Server Error in '/' Application.

Couldn't find field template for column Materials.source

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Exception: Couldn't find field template for column Materials.source

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[Exception: Couldn't find field template for column Materials.source]
Catalyst.Web.DynamicData.FilterTemplateFactory.GetVirtualPathWithModeFallback(String templateName, MetaColumn column, FilterControlMode mode) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\FilterTemplateFactory.cs:230
Catalyst.Web.DynamicData.FilterTemplateFactory.GetFieldTemplateVirtualPath(MetaColumn column, FilterControlMode mode, String uiHint) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\FilterTemplateFactory.cs:144
Catalyst.Web.DynamicData.FilterTemplateFactory.GetFieldTemplateVirtualPathWithCaching(MetaColumn column, FilterControlMode mode, String uiHint) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\FilterTemplateFactory.cs:157
Catalyst.Web.DynamicData.FilterTemplateFactory.CreateFieldTemplate(MetaColumn column, FilterControlMode mode, String uiHint) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\FilterTemplateFactory.cs:96
Catalyst.Web.DynamicData.DynamicFilterControl.CreateControl() in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterControl.cs:41
Catalyst.Web.DynamicData.DynamicFilterControl.OnInit(EventArgs e) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterControl.cs:90
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.AddedControl(Control control, Int32 index) +198
System.Web.UI.ControlCollection.Add(Control child) +80
System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) +106
System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) +443
System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) +51
System.Web.UI.WebControls.Repeater.DataBind() +75
Catalyst.Web.DynamicData.DynamicFilterRepeater.OnInit(EventArgs e) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterRepeater.cs:107
System.Web.UI.Control.InitRecursive(Control namingContainer) +333
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Control.InitRecursive(Control namingContainer) +210
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +378


Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053
<!-- [Exception]: Couldn't find field template for column Materials.source at Catalyst.Web.DynamicData.FilterTemplateFactory.GetVirtualPathWithModeFallback(String templateName, MetaColumn column, FilterControlMode mode) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\FilterTemplateFactory.cs:line 230 at Catalyst.Web.DynamicData.FilterTemplateFactory.GetFieldTemplateVirtualPath(MetaColumn column, FilterControlMode mode, String uiHint) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\FilterTemplateFactory.cs:line 144 at Catalyst.Web.DynamicData.FilterTemplateFactory.GetFieldTemplateVirtualPathWithCaching(MetaColumn column, FilterControlMode mode, String uiHint) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\FilterTemplateFactory.cs:line 157 at Catalyst.Web.DynamicData.FilterTemplateFactory.CreateFieldTemplate(MetaColumn column, FilterControlMode mode, String uiHint) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\FilterTemplateFactory.cs:line 96 at Catalyst.Web.DynamicData.DynamicFilterControl.CreateControl() in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterControl.cs:line 41 at Catalyst.Web.DynamicData.DynamicFilterControl.OnInit(EventArgs e) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterControl.cs:line 90 at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at System.Web.UI.WebControls.Repeater.CreateItem(Int32 itemIndex, ListItemType itemType, Boolean dataBind, Object dataItem) at System.Web.UI.WebControls.Repeater.CreateControlHierarchy(Boolean useDataSource) at System.Web.UI.WebControls.Repeater.OnDataBinding(EventArgs e) at System.Web.UI.WebControls.Repeater.DataBind() at Catalyst.Web.DynamicData.DynamicFilterRepeater.OnInit(EventArgs e) in D:\Catalyst\Projects\DynamicData\Project\Trunk\DynamicData\DynamicData\DynamicFilterRepeater.cs:line 107 at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) [HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown. at System.Web.UI.Page.HandleError(Exception e) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) at System.Web.UI.Page.ProcessRequest() at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) at System.Web.UI.Page.ProcessRequest(HttpContext context) at ASP.dynamicdata_custompages_materials_list_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\78833ec0\11503bef\App_Web_-p4xzg8p.0.cs:line 0 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) -->

When I use the same field but with a Contains or Equals FilterControlMode it works fine; no errors, completely expected behavior.

Here's the corresponding snippet from my Metadata class:

        [UIHint( "ReadOnlyText" )]
        [DisplayName("Source of Data")]
        [Filter(FilterMode=FilterControlMode.MultiSelect)]
        public object source { get; set; }

Also don't know if this is related or matters at all, but this particular page is a custom page template (it;s the only one with the DynamicFilter on it), and most of the fields are relying on Custom Field templates (hat make most of the fields read-only if the column I'm needing to search on here is a particular value.  Also, the rest of the application uses the ListDetails template for single-page editing, but this page is using the separate page list/edit model.

Anyway, thanks again for the tool, and any pointers you can give me here will be wonderful...
Oct 13, 2008 at 2:02 PM
Edited Oct 13, 2008 at 2:36 PM
I believe this is failing because the DynamicFilterControl is looking for a column named source_MultiSelect which does not exist.

I would suggest you implement a custom FilterTemplate.  You do this by extending FilterTemplateUserControlBase and implementing the virtual method GetLambdaExpression. 

Please see the following URL for details:  http://blogs.catalystss.com/blogs/josh_heyse/archive/2008/04/11/a-richer-dynamicfilterrepeater-part-4-custom-dynamicfiltercontrols-amp-expressions.aspx
Nov 19, 2008 at 4:57 PM
Hi,
I had the same problem.

        [UIHint( "ReadOnlyText" )]
        [DisplayName("Source of Data")]
        [Filter(FilterMode=FilterControlMode.MultiSelect)] change in <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <meta content="Word.Document" name="ProgId" /> <meta content="Microsoft Word 11" name="Generator" /> <meta content="Microsoft Word 11" name="Originator" /> <link href="file:///C:%5CDOKUME%7E1%5CRT%5CLOKALE%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel="File-List" /><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--> <style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 2.0cm 70.85pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Normale Tabelle"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->[UIHint("ForeignKey_MultiSelect")]<o:p></o:p>
        public object source { get; set; }

and in DynamicFilterform

<style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 2.0cm 70.85pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style>

 

<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <meta content="Word.Document" name="ProgId" /> <meta content="Microsoft Word 11" name="Generator" /> <meta content="Microsoft Word 11" name="Originator" /> <link href="file:///C:%5CDOKUME%7E1%5CRT%5CLOKALE%7E1%5CTemp%5Cmsohtml1%5C01%5Cclip_filelist.xml" rel="File-List" /><!--[if gte mso 9]><xml> <w:WordDocument> <w:View>Normal</w:View> <w:Zoom>0</w:Zoom> <w:HyphenationZone>21</w:HyphenationZone> <w:PunctuationKerning/> <w:ValidateAgainstSchemas/> <w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid> <w:IgnoreMixedContent>false</w:IgnoreMixedContent> <w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> <w:DontGrowAutofit/> </w:Compatibility> <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel> </w:WordDocument> </xml><![endif]--><!--[if gte mso 9]><xml> <w:LatentStyles DefLockedState="false" LatentStyleCount="156"> </w:LatentStyles> </xml><![endif]--> <style> <!-- /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:12.0pt; font-family:"Times New Roman"; mso-fareast-font-family:"Times New Roman";} @page Section1 {size:612.0pt 792.0pt; margin:70.85pt 70.85pt 2.0cm 70.85pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} --> </style> <!--[if gte mso 10]> <style> /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Normale Tabelle"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman"; mso-ansi-language:#0400; mso-fareast-language:#0400; mso-bidi-language:#0400;} </style> <![endif]-->

            <asp:DynamicFilterForm ID="DynamicFilterForm1" runat="server"  DataSourceID="GridDataSource"><o:p></o:p>

                <FilterTemplate><o:p></o:p>

                    <table><o:p></o:p>

                        <tr><o:p></o:p>

                            <td>FKVision:</td><o:p></o:p>

                            <td><asp:DynamicFilterControl ID="DynamicFilterControl2" runat="server" DataField="Tablename(source)" ></asp:DynamicFilterControl></td>                                               <o:p></o:p>

                            <td>Name:</td><o:p></o:p>

                            <td><asp:DynamicFilterControl ID="DynamicFilterControl3" runat="server" DataField="Name" ></asp:DynamicFilterControl></td>                                               <o:p></o:p>

                            <td><o:p></o:p>

                                <asp:LinkButton ID="SearchButton" runat="server" CommandName="Search" Text="Search"></asp:LinkButton><o:p></o:p>

                                <asp:LinkButton ID="ClearButton" runat="server" CommandName="Clear" Text="Clear"></asp:LinkButton><o:p></o:p>

                            </td><o:p></o:p>

                        </tr><o:p></o:p>

                    </table><o:p></o:p>

                </FilterTemplate><o:p></o:p>

            </asp:DynamicFilterForm><br /><o:p></o:p>

In DataField you have to insert the Foreign Tablename not the ForeignKey
than it works.

try Rudolf