Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
155
WebHierarchicalDataSource and SelectParameters
posted

Hello, I have a news table which contains the dates and id of a particular news entry and a child table with the actual newstexts in a particular language that reference a news entry in the parents table:

News(ID, DATE etc.) --> Newsdetails(ID, NEWS_ID (FK(NEWS), NEWS_TEXT, LANGUAGE)

a perfect situation for a whdg. Now I would like to be able to search for detail records (in particular the News_text field) and filter down the grid to show only the rows with childs that contain the searchtext. For that I tried to join the parent records with the child and expose a selectParameter

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT DISTINCT mas.ID FROM NEWS mas LEFT OUTER JOIN NEWSDETAILS det ON mas.ID = det.NEWS_ID WHERE det.NEWS_TEXT like '%'+:searchinput+'%'" EnableViewState="False">

     <SelectParameters>

         <asp:ControlParameter ControlID="txtSearch" Name="searchinput" PropertyName="Text" />

     SelectParameters>

asp:SqlDataSource>


<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" SelectCommand="SELECT ID, NEWS_ID, LANGUAGE_ID, NEWS_TEXT FROM NEWSDETAILS" EnableViewState="False">

asp:SqlDataSource>


<ig:WebHierarchicalDataSource ID="WebHierarchicalDataSource1" runat="server">

<DataViews>

    <ig:DataView ID="SqlDataSource1_DefaultView" DataMember="DefaultView" DataSourceID="SqlDataSource1" />

    <ig:DataView ID="SqlDataSource2_DefaultView" DataMember="DefaultView" DataSourceID="SqlDataSource2" />

DataViews>

<DataRelations>

    <ig:DataRelation ChildColumns="NEWS_ID" ChildDataViewID="SqlDataSource2_DefaultView" ParentColumns="ID" ParentDataViewID="SqlDataSource1_DefaultView" />

DataRelations>

ig:WebHierarchicalDataSource>

And a Standard WHDG connected to the Hierarchical Source. If I remove the SelectParameters, it does work good. However, I would like to be able to have a global search field, so I can enter a text and the SQLDataSource1 should be filtered to all records which contain this searchtext.

So, as soon as there is a SelectParameters  I get a "Object reference not set to an instance of an object." exception. If I connect a normal WebDataGrid to the SqlDataSource1, it does work fine. So the Problem only appears in combination with the WebHierarchicalDataSource.

What can I do to solve the Problem?

Parents Reply Children
No Data