ASP.NET equivalent to CFQUERY GROUP

B

Brent Mondoux

Hey everyone,

I'm trying to find the best non-spaghetti code way to do the
equivalent of a ColdFusion CFQUERY GROUP command so that I can display
a FAQ with categories as follows:

-- Example: Begin --


General
- What is Enlighten?

Client Profile
- How do I add a new client?
- How do I update a client profile?

Programs & Activities
- How do I setup a new program?
- How do I add an activity to a program?


-- Example: End --

Any ideas? Please email me back at (e-mail address removed)

Thanks.

Brent
 
B

Brent Mondoux

Found a solution to this, used a couple of queries to do the trick

<!-- #INCLUDE Virtual="../includes/header.aspx" -->
<!-- #INCLUDE Virtual="../includes/bofaq.aspx" -->

<script language="vb" runat="server">

Dim myFAQ As New boFAQ
Dim dstFAQCats As DataSet
Dim dstFAQs As DataSet
Dim dvwFAQs As DataView

Sub Page_Load
' Setup client object datasource
myFAQ.DSN = ConfigurationSettings.AppSettings("enlightenDSN")

' In the event of a new FAQ item, place message on page
If Not Request.QueryString("isnew") Is Nothing Then
lblStatusFAQ.Text = "FAQ item saved."
End If

If Not Page.IsPostBack Then
BuildList()
End If
End Sub

Sub BuildList()
dstFAQCats = myFAQ.getFAQCategoriesWithItems()
dstFAQs = myFAQ.getFAQSummary()
dvwFAQs = dstFAQs.Tables("tblFAQItem").DefaultView()

rptFAQs.DataSource = dstFAQCats
rptFAQs.DataMember = "tblFAQCategory"
rptFAQs.DataBind()
End Sub

Function FilterFAQs(intCatID As Integer) As DataView
dvwFAQs.RowFilter = "faqcategory_id=" & intCatID
Return dvwFAQs
End Function

</script>

<asp:label id="lblStatusFAQ" runat="server" Text="" />

<p><strong>Frequently Asked Questions</strong></p>

<asp:Repeater ID="rptFAQs" RunAt="server">
<ItemTemplate>
<p><strong><%# Container.DataItem("category_name") %></strong>
<asp:DataGrid Width="500" BorderWidth="0" CellPadding="3"
CellSpacing="0"
ShowHeader="False" HeaderStyle-BackColor="#F6F6F6"
AlternatingItemStyle-BackColor="AliceBlue"
AutoGenerateColumns="False" DataKeyField="faqitem_id"
DataSource='<%# FilterFAQs(
Container.DataItem("faqcategory_id") ) %>' runat="server">
<Columns>
<asp:BoundColumn Visible="False" HeaderText=""
DataField="faqitem_id" SortExpression="faqitem_id" />
<asp:HyperLinkColumn DataTextField="summary"
DataNavigateUrlField="faqitem_id"
DataNavigateUrlFormatString="../caseworker/faqitem.aspx?fid={0}"
ItemStyle-Width="500px" HeaderText="Item" />
</Columns>
</asp:DataGrid></p>
</ItemTemplate>
</asp:Repeater>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top