Demo of Listing the FAQ Categories for the Master/Detail Report

This demo illustrates how to list the categories from the tblFAQCategory table. It's fairly straightforward, nothing fancy going on here! :-)


FAQ CategoryFAQs
Application Object The FAQs for the FAQCategory will go here...
Arrays The FAQs for the FAQCategory will go here...
ASP.NET The FAQs for the FAQCategory will go here...
Cookies The FAQs for the FAQCategory will go here...
Databases, Errors The FAQs for the FAQCategory will go here...
Databases, General The FAQs for the FAQCategory will go here...
Databases, Queries The FAQs for the FAQCategory will go here...
Dates and Times The FAQs for the FAQCategory will go here...
Email The FAQs for the FAQCategory will go here...
FileSystemObject The FAQs for the FAQCategory will go here...
Forms The FAQs for the FAQCategory will go here...
Functions and Subroutines The FAQs for the FAQCategory will go here...
Getting Started The FAQs for the FAQCategory will go here...
Math Functions The FAQs for the FAQCategory will go here...
Networking The FAQs for the FAQCategory will go here...
Regular Expressions The FAQs for the FAQCategory will go here...
Security The FAQs for the FAQCategory will go here...
Session Object The FAQs for the FAQCategory will go here...
Strings The FAQs for the FAQCategory will go here...
System.IO Namespace Classes The FAQs for the FAQCategory will go here...
The Nature of Things The FAQs for the FAQCategory will go here...
Uploading The FAQs for the FAQCategory will go here...
XML The FAQs for the FAQCategory will go here...


Source Code
<%@ Import Namespace = "System.Data" %>
<%@ Import Namespace = "System.Data.SQLClient" %>
<script language="VB" runat="server">
  Sub Page_Load(sender as Object, e as EventArgs)
    BindData()
  End Sub
	
	
  Sub BindData()
    '1. Create a connection
    Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("connectionString"))

    '2. Create the command object, passing in the SQL string
    Const strSQL as String = "SELECT FAQCategoryID, Name FROM tblFAQCategory ORDER BY Name"
    Dim myCommand as New SqlCommand(strSQL, myConnection)

    'Set the datagrid's datasource to the datareader and databind
    myConnection.Open()
    dgMasterDetail.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
    dgMasterDetail.DataBind()
    myConnection.Close()
  End Sub
</script>

  <asp:DataGrid runat="server" id="dgMasterDetail"
         AutoGenerateColumns="False"
         Font-Name="Verdana" Width="85%"
         Font-Size="11pt" HorizontalAlign="Center">
         
    <HeaderStyle BackColor="Navy" ForeColor="White" HorizontalAlign="Center"
                 Font-Size="14pt" Font-Bold="True" />
   
    <Columns>
      <asp:BoundColumn DataField="Name" HeaderText="FAQ Category" />
      <asp:TemplateColumn HeaderText="FAQs">
        <ItemTemplate>
          <i>The FAQs for the FAQCategory will go here...
        </ItemTemplate>
      </asp:TemplateColumn>
    </Columns>
  </asp:DataGrid>


[Return to the article]