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
20
Proper way to filter child rows
posted

quick rundown of what im doing, i have a list of Parents with Children as normal, both the parents and children have macaddresses (field mac), the children are associated to the parents by a field "assocmac" ... the issue is i needed a way to search both the parents and children for a mac, filtering doesnt really do this as it is because its only by group, i need to filter out the entire source 

what i did was create a textbox with a button where i can enter a part of an address and it will search both databases and then update the sqldatasources and rebind the whdg... 

problem is that after it searches, the parents get filtered (i see them all but only the ones with children matching the criteria have drop down arrows... but when i click the drop down arrow it shows all the children not the filtered ones from my filtered datasource.... and if i click to sort a column on the parent.. tada all of the parents now have drop downs.... 

 

its as if somewhere its loosing the changes i made to the datasources 

page is just 2 sqldatasources, 1 whds and 1 whdg here is the actual code im using on the button press

 

 

   Dim ap As Boolean = False

        Dim ObjConnection As New SQLiteConnection(connString)

        Dim ObjCommand As New SQLiteCommand("select mac from aps where mac like '%" & WebTextEditor1.Text & "%'", ObjConnection)

        ObjCommand.CommandType = CommandType.Text

        ObjConnection.Open()

        Dim i As String = ObjCommand.ExecuteScalar

        If i = "" Then

            ObjCommand.CommandText = "select assocmac from clients where mac like '%" & WebTextEditor1.Text & "%'"

            i = ObjCommand.ExecuteScalar

        Else

            ap = True

        End If

        ObjConnection.Close()

        ObjCommand.Dispose()

        ObjConnection.Close()

        ObjConnection.Dispose()

        If ap = True Then

            SqlDataSource1.SelectCommand = "SELECT * FROM [APs] where mac like '%" & WebTextEditor1.Text & "%'"

            SqlDataSource2.SelectCommand = "SELECT * FROM [CLIENTs]"

            SqlDataSource1.DataBind()

            SqlDataSource2.DataBind()

            WebHierarchicalDataGrid1.Rows.Clear()

            WebHierarchicalDataSource1.DataBind()

            WebHierarchicalDataGrid1.DataBind()

        Else

            SqlDataSource1.SelectCommand = "SELECT * FROM [APs]"

            SqlDataSource2.SelectCommand = "SELECT * FROM [CLIENTs] where mac like '%" & WebTextEditor1.Text & "%'"

            SqlDataSource1.DataBind()

            SqlDataSource2.DataBind()

            WebHierarchicalDataGrid1.Rows.Clear()

            WebHierarchicalDataSource1.DataBind()

            WebHierarchicalDataGrid1.DataBind()

        End If

 

Parents
No Data
Reply
  • 49378
    posted

    Hi cchance,

    It has been a while since your post, however in case you are still in need of assistance I would be glad to help.

    You are presenting a very interesting scenario regarding filtering in the WebHierarchicalDataGrid. The approach you have employed is on the right tracks, however as far as I understand you are filtering your data source on the button click only.

    Note that the grid is rebound to its data source on every postback. Furthermore, if you are otherwise binding the grid from your markup, on every postback which is not caused by your by button being clicked, the data source is repopulated to its original state. Hence you should manually ensure the consistency of your data source on every Page_Load.

    Please contact me if you have any questions.

    Best Regards,

    Petar Ivanov
    Developer Support Engineer
    Infragistics, Inc.
    http://www.infragistics.com/support

Children
No Data