Disclaimer: 1st post - so I'm a newb....please point me to correct forum if this is not the appropriate one for this issue.
I have an ajax accordion that contains a listview in each pane. The listview's layouttemplate contains a datapager. I'm querying data contained in a SQL database in the codebehind. The number of accordion panes is determined by a field called "category" and under each pane is a listview containing the title and a pic of the software associated with that category. So I am binding the accordion then binding the listviews essentially. When I expand one of the panes and attempt to page through the listview (i.e. click on the "2" or "3") there are two primary issues. #1 - I have to click the the page buttons (i.e. the number 2 or 3) twice to get the listview to do anything and #2 - the same data is listed no matter what page it think's I'm on. So for example, on page 1 the listview displays the software "Acrobat", "Illustrator", "Photoshop" - when I click on page 2 (twice) I still see "Acrobat", "Illustrator", "Photoshop" when I should see "InDesign, "Dreamweaver", and "Flexbuilder". It appears to be posting back each time I click the buttons in the datapager but I still see this same behavior.
Here's my markup:
ContentCssClass="accordionContent" CssClass="accordion"
HeaderCssClass="accordionHeader"
HeaderSelectedCssClass="accordionHeaderSelected" SuppressHeaderPostbacks="true" Width="100%" RequireOpenedPane="true">
OnPagePropertiesChanging="lvFilterSW_PagePropertiesChanging" OnPagePropertiesChanged="lvFilterSW_PagePropertiesChanged">
Text='<% #Eval("title") %>'>
Here is my code behind (what's relevant to this question):
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Dim sParameter As String = "PointlessForThisQuestion" 'Used for building custom SQL statements in other parts of the code
BindAccordion(sParameter)
End If
End Sub
Private Sub BindAccordion(ByVal sParameter As String)
Dim connStringProduct As String = ConfigurationManager.ConnectionStrings("SoftwareTestConnectionString2").ConnectionString
Dim sql As String = "SELECT DISTINCT category FROM ApprovedSoftware WHERE Availability='Global'"
Dim da As SqlDataAdapter = New SqlDataAdapter(sql, connStringProduct)
Dim dt As New DataTable
da.Fill(dt)
Accordion1.DataSource = dt.DefaultView
Accordion1.DataBind()
Accordion1.RequireOpenedPane = False
Accordion1.SelectedIndex = -1
End Sub
Private Sub Accordion1_ItemDataBound(ByVal sender As Object, ByVal e As AjaxControlToolkit.AccordionItemEventArgs) Handles Accordion1.ItemDataBound
If e.ItemType = AccordionItemType.Content Then
Dim listview1 As ListView = e.AccordionItem.FindControl("lvFilterSW")
Dim hidField As HiddenField = e.AccordionItem.FindControl("hf1")
BindGrid(listview1, hidField.Value, "")
End If
End Sub
Private Sub BindGrid(ByVal lvMain As ListView, ByVal category As String, ByVal sql As String)
Dim connStringProduct As String = ConfigurationManager.ConnectionStrings("SoftwareTestConnectionString2").ConnectionString
Dim sql As String = "SELECT DISTINCT title, productPic FROM ApprovedSoftware WHERE category='" & category & _
"' AND Availability='Global'"
Dim da As SqlDataAdapter = New SqlDataAdapter(sql, connStringProduct)
da.SelectCommand.Parameters.Add("@title", SqlDbType.VarChar, 20).Value = Title
Dim dt As New DataTable
da.Fill(dt)
lvMain.DataSource = dt
lvMain.DataBind()
End Sub
Protected Sub lvFilterSW_PagePropertiesChanging(ByVal sender As Object, ByVal e As PagePropertiesChangingEventArgs)
Dim dp As New DataPager
Dim lv As New ListView
Dim hf As HiddenField
Dim sql As String = ""
'lv = Me.Accordion1.FindControl("lvFilterSW")
lv = CType(Me.Accordion1.FindControl("lvFilterSW"), ListView)
'dp = lv.FindControl("dplvFilterSW")
dp = CType(lv.FindControl("dplvFilterSW"), DataPager)
hf = Me.Accordion1.FindControl("hf1")
dp.SetPageProperties(e.StartRowIndex, e.MaximumRows, False)
BindGrid(lv, hf.Value, sql)
End Sub
Protected Sub dplvFilterSW_PreRender(ByVal sender As Object, ByVal e As EventArgs)
Dim dp As New DataPager
Dim lv As New ListView
Dim hf As HiddenField
Dim sql As String = ""
'lv = Me.Accordion1.FindControl("lvFilterSW")
lv = CType(Me.Accordion1.FindControl("lvFilterSW"), ListView)
'dp = lv.FindControl("dplvFilterSW")
dp = CType(lv.FindControl("dplvFilterSW"), DataPager)
hf = Me.Accordion1.FindControl("hf1")
BindGrid(lv, hf.Value, sql)
End Sub
I know the code is repetive but for now I'm trying to just get this working then I will clean up the code. I've tried changing the datasource from a dataTable to a DataSet but still get the same results.
Let me know if any other info is needed, be glad to pass along.
Thanks in advance.
1 Reply
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
MikePosted Jun 3, 2011, 4:04 PM