Example E2342
Visible to All Users

How to create the FAQ Page using the ASPxNavBar

Files to look at:

The example demonstrates how to create the ASPxNavBar groups and items at runtime to create a FAQ page.
Data can be obtained from any type of a datasource. For example, the data can be obtained from the Access database file using the OLE DB provider.

The sample was built from the kindly provided How to use the ASPxNavBar with an Access or SQL datasource suggestion article, containing the URL to the tutorial video file.

Example Code

Default.aspx
ASPx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <%@ Register Assembly="DevExpress.Web.v13.2, Version=13.2.15.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to create the FAQ Page using the ASPxNavBar</title> <style type="text/css"> .heading { font-size: large; color: Blue; } .Question { color: Gray; font-size: 11pt; } .Question img { vertical-align: middle; } .Question span { vertical-align: middle !important; } .Answer { font-size: 11pt; padding-left: 35px !important; padding-top: 8px; padding-bottom: 8px; } .defaultStyle { padding-left: 0px; list-style-type: none; margin: 0px; } .groupPadding { padding-left:0px; } </style> </head> <body> <form id="form1" runat="server"> <div style="min-height: 500px;"> <div class="heading"> Frequently Asked Questions </div> <div style="padding-left: 10px; padding-top: 10px;"> <dx:ASPxNavBar ID="navFAQ" runat="server" ExpandButtonPosition="Left" AutoCollapse="True" GroupSpacing="5px" EncodeHtml="False" CssPostfix="None" CssClass="defaultStyle"> <GroupHeaderStyle CssClass="Question" ImageSpacing="8px" /> <CollapseImage Url="~/Images/nbCollapse.png" /> <ExpandImage Url="~/Images/nbExpand.png" /> <ItemStyle CssClass="Answer defaultStyle" /> <GroupContentStyle CssClass="groupPadding" /> </dx:ASPxNavBar> </div> </div> </form> </body> </html>
Default.aspx.cs(vb)
C#
using System; using System.Configuration; using System.Data.OleDb; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { Load_FAQ(); } } public void Load_FAQ() { string SQL = "SELECT [Sort], [Question], [Answer] FROM [FAQ] ORDER BY [Sort], [Question]"; string Question = null; string Answer = null; int i = 0; OleDbConnection conn = new OleDbConnection(ConfigurationManager.ConnectionStrings["DB_Conn_FAQ"].ConnectionString); OleDbCommand SelectCommand = new OleDbCommand(SQL, conn); try { conn.Open(); OleDbDataReader Reader = SelectCommand.ExecuteReader(); while (Reader.Read()) { if (Reader.HasRows) { Question = Reader["Question"].ToString(); Answer = Reader["Answer"].ToString(); navFAQ.Groups.Add(Question); navFAQ.Groups[i].Items.Add(Answer); } i += 1; } } catch (Exception ex) { } finally { conn.Close(); conn.Dispose(); SelectCommand.Dispose(); } } }

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.