|
-
Oct 28th, 2008, 08:44 AM
#1
Thread Starter
Frenzied Member
[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:
Private Sub LoadAccordion()
Dim dt As DataTable
Dim stClientNO As String = "0"
Dim cmd As New XSQL("XXXXX", 2)
Dim stHeadString As String
Try
cmd.AddStrParam("@clClient", txtClientNo.Text, 20)
cmd.AddStrParam("@clName", txtClientName.Text, 100)
dt = cmd.ExecuteDS("USP_GetClientAddress").Tables(0)
If dt.Rows.Count = 0 Then
lblError.Text = "There were no results to the query. Please try again."
Else
'loop and add panes
Dim ap1 As New AccordionPane
For Each row As DataRow In dt.Rows
'if new number add header
If row("claClient") <> stClientNO Then
If stClientNO <> "0" Then
Acc1.Panes.Add(ap1)
'ap1.Controls.Clear() 'nothing appears using this
End If
stHeadString = row("claClient") & " - " & row("clname")
ap1.HeaderContainer.Controls.Add(New LiteralControl(stHeadString))
stClientNO = row("claClient")
End If
'add content
ap1.ContentContainer.Controls.Add(New LiteralControl(ContentString(row)))
Next
lblError.Text = ""
End If
Catch ex As Exception
lblError.Text = ex.Message
End Try
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.
-
Oct 28th, 2008, 01:21 PM
#2
Thread Starter
Frenzied Member
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:
Private Sub AddPanel(ByVal dTable As DataTable, ByVal stGroupID As String, ByVal stGroupName As String)
dTable.DefaultView.RowFilter = "claClient = " & stGroupID
Dim ap1 As New AccordionPane
Dim stHeadString As String = stGroupID & " - " & stGroupName
ap1.HeaderContainer.Controls.Add(New LiteralControl(stHeadString))
For Each dRow As DataRowView In dTable.DefaultView
ap1.ContentContainer.Controls.Add(New LiteralControl(dRow("clname") & vbCrLf))
Next
Acc1.Panes.Add(ap1)
End Sub
Private Sub BindAccordion()
Dim dt As DataTable
Dim stClientNO As String = "0"
Dim cmd As New XSQL("XXXXX", 2)
Dim i As Integer = 1
Try
cmd.AddStrParam("@clClient", txtClientNo.Text, 20)
cmd.AddStrParam("@clName", txtClientName.Text, 100)
dt = cmd.ExecuteDS("USP_GetClientAddress").Tables(0)
If dt.Rows.Count = 0 Then
lblError.Text = "There were no results to the query. Please try again."
Else
'loop and add panes
For Each row As DataRow In dt.Rows
'if new number add header
If stClientNO <> row("claClient") Then
AddPanel(dt, row("claClient"), row("clname"))
stClientNO = row("claClient")
End If
Next
lblError.Text = ""
End If
Catch ex As Exception
lblError.Text = ex.Message
End Try
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|