Having Problems Getting Panel Bar to work properly...

3 posts, 1 answers
  1. Robert Gouin
    Robert  Gouin avatar
    11 posts
    Member since:
    Oct 2009

    Posted 04 Nov 2009 Link to this post

    Ok, so I would like this panel bar to be built and use a data source but the problem is that I use 3 tables for the source.

    I have

      tblCategory
    -cID                    Auto
    -cName              String
    -cDescription     String
    -isDeleted          Boolean

      tblProducts
    -pID                   Auto
    -pNumber          String
    -pName             String
    -isDeleted         Boolean

    and because products can be listed under multiple categories I have an intermediate table called

      tblInfo
    -iID      Integer
    -cID     Integer
    -pID     Integer

    Now I have created a table adaptor I call Navigation which loads like ...
    SELECT        c.cID, c.cName, c.cDescription, p.pID, p.pNumber, p.pName
    FROM            ((tblCategories c INNER JOIN
                             tblInfo i ON c.cID = i.cID) INNER JOIN
                             tblProducts p ON i.pID = p.pID)
    WHERE        (c.isDeleted = False) AND (p.isDeleted = False)
    ORDER BY c.cOrder, p.pName

    so I have

    -cID
    -cName
    -cDescriptino
    -pID
    -pNumber
    -pName

    and what I would like is for all the products to be listed under the categories.  Below is a sampling output of the table.

    2 Skin Cleansers d 25 311 C-Mollient Gel Cleanser
    2 Skin Cleansers d 20 043 LactiCleanse Creamy
    2 Skin Cleansers d 21 243 LactiCleanse Foamy
    2 Skin Cleansers d 22 247 Multi HA Cleanser
    2 Skin Cleansers d 19 248 NeutraCleanse
    2 Skin Cleansers d 23 286 RosaCleanse Creamy
    2 Skin Cleansers d 24 287 RosaCleanse Foamy
    3 Anti-Photoaging Anti Photo Aging 8 270 CEGA 30+FERULIC Cream
    3 Anti-Photoaging Anti Photo Aging 3 269 CEGA 30+FERULIC Serum
    3 Anti-Photoaging Anti Photo Aging 4 205 CEGA Eye Area
    3 Anti-Photoaging Anti Photo Aging 32 206 C-Mollient Serum
    3 Anti-Photoaging Anti Photo Aging 27 212 C-mollient

    But when I try to specify 2 as the parent and pID as the child it gives me errors..

    [ArgumentException: These columns don't currently have unique values.]

    any help would be greatly appreciated.



  2. Answer
    Vesko
    Vesko avatar
    122 posts
    Member since:
    Mar 2009

    Posted 09 Nov 2009 Link to this post

    You need to iterate through your data records and create the panel bar items manually.

    There is a similar article here.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Robert Gouin
    Robert  Gouin avatar
    11 posts
    Member since:
    Oct 2009

    Posted 14 Nov 2009 Link to this post

    Thank you very much for that tutorial, it worked great, but in case someone wants a different way, while waiting for this reply I wrote a function that just makes a temporary table, and that works great as well.

        Private Function makeNav() As DataTable 
     
            Dim rsCat As EnumerableRowCollection(Of cn.tblCategoriesRow) = New cnTableAdapters.tblCategoriesTableAdapter().GetData().AsEnumerable() 
            Dim rsInfo As EnumerableRowCollection(Of cn.tblInfoRow) = New cnTableAdapters.tblInfoTableAdapter().GetData().AsEnumerable() 
            Dim rsPage As EnumerableRowCollection(Of cn.tblProductsRow) = New cnTableAdapters.tblProductsTableAdapter().GetData().AsEnumerable() 
     
            Dim table As New DataTable() 
     
            Dim currentCat As Integer = 0 
            Dim lProduct = Nothing 
     
            table.Columns.Add("ID"
            table.Columns.Add("parentID"
            table.Columns.Add("Text"
            table.Columns.Add("productID"
     
            Dim lCat = From c In rsCat Select c 
     
            For Each cat In lCat 
                table.Rows.Add(New Object() {"cat" & cat.cID, Nothing, cat.cName, Nothing}) 
            Next 
     
            For Each cat In lCat 
                currentCat = cat.cID 
                lProduct = From i In rsInfo _ 
                           From p In rsPage _ 
                           Where p.pID = i.pID And i.cID = currentCat _ 
                           Order By p.pName _ 
                           Select uniqueID = i.iID, pName = p.pName, prodID = p.pID 
                For Each prod In lProduct 
                    table.Rows.Add(New Object() {prod.uniqueID, "cat" & currentCat, prod.pName, prod.prodID}) 
                Next 
            Next 
     
            Return table 
        End Function 

    and then simply bind it.

        Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load 
            pNav.DataSource = makeNav() 
            pNav.DataFieldID = "ID" 
            pNav.DataFieldParentID = "parentID" 
            pNav.DataTextField = "text" 
            pNav.DataValueField = "productID" 
            pNav.DataBind() 
        End Sub 

    Now I never said I knew what I was doing, I just said I could do it ;-)


Back to Top