Results 1 to 2 of 2

Thread: [Semi-Resolved] [2005] Adding AJAX accordion panes dynamically

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    [Semi-Resolved] [2005] Adding AJAX accordion panes dynamically

    Hey,
    Having a little issue here. I am trying to loop through a datatable and create a new pane for each group of client numbers. I think I am having trouble with how I dim my new accordion pane. I am trying to use just one variable but it doesn't seem to like that as it tries to add everything togeter into one pane.

    vb Code:
    1. Private Sub LoadAccordion()
    2.         Dim dt As DataTable
    3.         Dim stClientNO As String = "0"
    4.         Dim cmd As New XSQL("XXXXX", 2)
    5.         Dim stHeadString As String
    6.  
    7.         Try
    8.             cmd.AddStrParam("@clClient", txtClientNo.Text, 20)
    9.             cmd.AddStrParam("@clName", txtClientName.Text, 100)
    10.             dt = cmd.ExecuteDS("USP_GetClientAddress").Tables(0)
    11.             If dt.Rows.Count = 0 Then
    12.                 lblError.Text = "There were no results to the query. Please try again."
    13.             Else
    14.                 'loop and add panes
    15.                 Dim ap1 As New AccordionPane
    16.                 For Each row As DataRow In dt.Rows
    17.                     'if new number add header
    18.                     If row("claClient") <> stClientNO Then
    19.                         If stClientNO <> "0" Then
    20.                             Acc1.Panes.Add(ap1)
    21.                             'ap1.Controls.Clear() 'nothing appears using this
    22.                         End If
    23.                         stHeadString = row("claClient") & " - " & row("clname")
    24.                         ap1.HeaderContainer.Controls.Add(New LiteralControl(stHeadString))
    25.                         stClientNO = row("claClient")
    26.                     End If
    27.                     'add content
    28.                     ap1.ContentContainer.Controls.Add(New LiteralControl(ContentString(row)))
    29.                 Next
    30.                 lblError.Text = ""
    31.             End If
    32.         Catch ex As Exception
    33.             lblError.Text = ex.Message
    34.         End Try
    35.  
    36.  
    37.     End Sub

    I know my logic is flawed but what would be the best way to get this working?

    Thanks!
    Last edited by Besoup; Oct 28th, 2008 at 01:22 PM.

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2001
    Location
    Mass USA
    Posts
    1,674

    Re: [2005] Adding AJAX accordion panes dynamically

    I think that I put something together to do what I need... code isn't completed but it's getting the template done the way I want:

    vb Code:
    1. Private Sub AddPanel(ByVal dTable As DataTable, ByVal stGroupID As String, ByVal stGroupName As String)
    2.  
    3.         dTable.DefaultView.RowFilter = "claClient = " & stGroupID
    4.         Dim ap1 As New AccordionPane
    5.         Dim stHeadString As String = stGroupID & " - " & stGroupName
    6.         ap1.HeaderContainer.Controls.Add(New LiteralControl(stHeadString))
    7.         For Each dRow As DataRowView In dTable.DefaultView
    8.             ap1.ContentContainer.Controls.Add(New LiteralControl(dRow("clname") & vbCrLf))
    9.         Next
    10.         Acc1.Panes.Add(ap1)
    11.  
    12.     End Sub
    13.     Private Sub BindAccordion()
    14.         Dim dt As DataTable
    15.         Dim stClientNO As String = "0"
    16.         Dim cmd As New XSQL("XXXXX", 2)
    17.  
    18.         Dim i As Integer = 1
    19.         Try
    20.             cmd.AddStrParam("@clClient", txtClientNo.Text, 20)
    21.             cmd.AddStrParam("@clName", txtClientName.Text, 100)
    22.             dt = cmd.ExecuteDS("USP_GetClientAddress").Tables(0)
    23.             If dt.Rows.Count = 0 Then
    24.                 lblError.Text = "There were no results to the query. Please try again."
    25.             Else
    26.                 'loop and add panes
    27.                 For Each row As DataRow In dt.Rows
    28.                     'if new number add header
    29.                     If stClientNO <> row("claClient") Then
    30.                         AddPanel(dt, row("claClient"), row("clname"))
    31.                         stClientNO = row("claClient")
    32.                     End If
    33.                 Next
    34.                 lblError.Text = ""
    35.             End If
    36.         Catch ex As Exception
    37.             lblError.Text = ex.Message
    38.         End Try
    39.     End Sub

    Gonna mark semi-Resolved incase someone can offer a better way to accomplish this.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width