[2008] Get data from listview/accordion
Guys,
I'm using the accordion control from the ajaxtoolkit. I have it displaying data from an xml file with a custom control, but I now need to get data back out.
How can I cycle thru the items in the accordion control and get the data entered? I need to save down a new xml file.
Here you can see where I am setting up the control...
Thanks
Bob
HTML Code:
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Label ID="DPEID" runat="server" Font-Bold="True" Font-Underline="True"
ForeColor="#006600" Text="DPEID" Width="70px"></asp:Label>
<cc1:Accordion ID="accMain" runat="server" AutoSize="None"
FadeTransitions="true"
TransitionDuration="200"
FramesPerSecond="40"
RequireOpenedPane="false"
SuppressHeaderPostbacks="true"
DataSourceID="xmlDataSourceSections"
onitemdatabound="accMain_ItemDataBound">
<HeaderTemplate>
<asp:Label ID="SectionNameLabel" runat="server" Font-Bold="true" Font-Size="Larger"
Text='<%# (Container.DisplayIndex + 1).ToString() + ". " + XPath("@SectionName")%>' />
</HeaderTemplate>
<ContentTemplate>
<%--The content template for the Accordion Template which is a ListView--%>
Color="#006600" Text="Comment" Width="800px"></asp:Label>
<br />
<asp:ListView ID="lstQuestions" runat="server">
<ItemTemplate>
<%--call the QuestionControl--%>
<Custom:QuestionControl runat="server" ID="customControl" QCategory='<%#Eval("Category") %>' QVDSCode='<%#Eval("VDSCode") %>' QYesno='<%#Eval("YesNo") %>' QComment='<%#Eval("Comment") %>' QText='<%#Eval("Text") %>' DocumentLink='<%#Eval("DocumentLink") %>' />
<br />
<br />
</ItemTemplate>
<LayoutTemplate>
<div ID="itemPlaceholderContainer" runat="server">
<span ID="itemPlaceholder" runat="server"/>
</div>
</LayoutTemplate>
</asp:ListView>
<%--End of Accordion content Template--%>
</ContentTemplate>
</cc1:Accordion>
Code:
Protected Sub accMain_ItemDataBound(ByVal sender As Object, ByVal e As AccordionItemEventArgs)
Dim itemIndex As Integer = e.ItemIndex
Dim itemType As AccordionItemType = e.ItemType
If itemType = AccordionItemType.Content Then
Dim document As XDocument = XDocument.Load("D:\physical.xml")
Dim sectionName As String = XPathBinder.Eval(DataBinder.GetDataItem(e.AccordionItem), "@SectionName").ToString()
Dim questions = From question In document.Descendants("Question") _
Where question.Parent.Attribute("SectionName").Value = sectionName _
Select Text = question.Element("Text").Value, _
DocumentLink = question.Element("DocumentLink").Value, _
Comment = question.Element("Comment").Value, _
VDSCode = question.Element("VDSCode").Value, _
Category = question.Element("Category").Value, _
YesNo = question.Element("YesNo").Value
Dim lstQuestions As ListView = TryCast(e.AccordionItem.FindControl("lstQuestions"), ListView)
lstQuestions.DataSource = questions
lstQuestions.DataBind()
End If
end sub