Demo of a Scrollable DataGrid

This DataGrid's contents are scrollable, since the height is set to a hardcoded 300px.

FAQ IDQuestionViews
181How can I format numbers and date/times using ASP.NET? For example, I want to format a number as a currency.964,702
161How can I convert a Recordset into an array? Also, how can I convert an array into a Recordset?238,089
115I am using Access and getting a 80004005 error (or a [Microsoft][ODBC Microsoft Access Driver] The Microsoft Jet database engine cannot open the file '(unknown)' error) when trying to open a connection! How can I fix this problem?233,530
83How can I quickly sort a VBScript array? 230,033
190How do I display data on a web page using arrays instead of Do...While...MoveNext...???...186,006
106How can I find out if a record already exists in a database? If it doesn't, I want to add it.183,511
118When I get a list of all files in a directory via the FileSystemObject, they aren't ordered in any reasonable way. How can I sort the files by name? Or by size? Or by date created? Or... 168,750
30For session variables to work, must the Web visitor have cookies enabled?133,635
14Can I send emails without using CDONTS?130,322
149How can I remove multiple spaces between words in a string? That is, if I have: Hi    there how can I get: Hi there?129,557
153How can I take the result of a SELECT...MULTIPLE or a group of same-named checkboxes and turn it into a query? That is, if the user selects 3 answers, how can I construct a query that looks for all 3?128,350
163How do I convert a string into an Integer?123,762
107** UPDATED 24 June 2003 **: Why am I getting "Operation must use an updateable query" errors?119,416
180How can I install Personal Web Server (PWS) onto Windows XP Home edition?116,884
47How can I validate an email address using VBscript?115,252
13How do you send email attachments through an ASP page?111,649
172How can I display images that reside in my database through an ASP page?110,298
63How do I put an array into a Session or Application "variable"? How do I then use it on the next ASP page?108,962
89How can I sort a VB Script array in ways other than by case-sensitive alphanumeric order, like numeric value, length of string, or even randomly?105,385
142How can I use application-level variables to cache information?97,894
79**UPDATED 1 April 2002** How do I get the record number of a just added record? 97,514
29How can I determine if a visitor has cookies support enabled in his/her browser?94,329
38How can I dynamically change the action of a form?92,236
160Why do I get the error "The application is using arguments that are of the wrong type, are out of acceptable range, or are in conflict with one another" when I try to open a recordset?91,729
61How can I treat some other web page as data on my own site?91,306

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)
    If Not Page.IsPostBack then
	End If
  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 TOP 25 FAQID, Description, ViewCount FROM tblFAQ ORDER BY ViewCount DESC"
    Dim myCommand as New SqlCommand(strSQL, myConnection)

    'Set the datagrid's datasource to the datareader and databind
    dgPopularFAQs.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
  End Sub

<div style="height:300px; width:100%; overflow:auto;">
    <asp:DataGrid runat="server" id="dgPopularFAQs"
         Font-Name="Verdana" Width="80%"
         Font-Size="11pt" HorizontalAlign="Center">
    <HeaderStyle BackColor="Navy" ForeColor="White" HorizontalAlign="Center"
                 Font-Size="14pt" Font-Bold="True" />
      <asp:BoundColumn DataField="FAQID" HeaderText="FAQ ID" 
                ItemStyle-HorizontalAlign="Center" />
      <asp:BoundColumn DataField="Description" HeaderText="Question" />
      <asp:BoundColumn DataField="ViewCount" HeaderText="Views"
                ItemStyle-HorizontalAlign="Right" />

[Return to the article]