Displaying the FAQs with a Category Name

This simple demo illustrates showing a list of FAQs with each FAQ's category name listed as well. Note that the SQL statement only retrieves FAQs whose FAQID is less than or equal to 25. (Hence the reason you're not seeing all ~190 FAQs.)

FAQ IDCategoryFAQ Question
2StringsHow do you convert a string to all uppercase or all lowercase?
12EmailHow can I display line breaks in an email message?
14EmailCan I send emails without using CDONTS?
15StringsHow can I determine the length of a string (how many characters are in a string)?
17StringsHow can I find the position of a certain character (or substring) within a string?
19Dates and TimesHow can I return the current date/time?
20Functions and SubroutinesWhat is recursion?
23FileSystemObjectWhat, exactly, is the FileSystemObject?
25EmailHow can I send an email using CDONTS?
8Databases, GeneralHow do you create a database table through a SQL statement (via an ASP page, perhaps)?
16Dates and TimesUsing VBScript, how can I determine if a variable is a valid date or not?
18Dates and TimesHow can I easily display a nicely formatted date variable?
24FileSystemObjectHow can I read the contents of a text file through an ASP page?
7ArraysHow do I dynamically resize an array?
11EmailHow can I have my ASP page send HTML-formatted email?
10Databases, GeneralHow can I tell what version of ADO I am using?
13EmailHow do you send email attachments through an ASP page?
21ArraysHow can I determine the upper or lower bounds of an array?
22EmailHow can I validate an email adress using Jscript?

Source Code
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="vb" runat="server">
  'Create a connection
  Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))

  Sub Page_Load(sender as Object, e as EventArgs)
    If Not Page.IsPostBack then
    End If
  End Sub

  Sub BindData()
    '2. Create the command object, passing in the SQL string
    Const strSQL as String = "SELECT FAQID, F.FAQCategoryID, F.Description, FC.Name AS CategoryName FROM tblFAQ F INNER JOIN tblFAQCategory FC ON F.FAQCategoryID = FC.FAQCategoryID WHERE FAQID <= 25"

    'Set the datagrid's datasource to the datareader and databind
    Dim resultsDataSet as New DataSet()
    Dim myDataAdapter as SqlDataAdapter = New SqlDataAdapter(strSQL, myConnection) 

    dgPopularFAQs.DataSource = resultsDataSet
  End Sub


    <asp:datagrid id="dgPopularFAQs" runat="server"
	    <asp:BoundColumn DataField="FAQID" ItemStyle-Width="10%"
				ItemStyle-HorizontalAlign="Center" HeaderText="FAQ ID" />
		<asp:BoundColumn DataField="CategoryName" HeaderText="Category" />
	    <asp:BoundColumn DataField="Description" HeaderText="FAQ Question" />	  

[Return to the article]