SendingPage.aspx Demo

This demo shows how to send a DataGrid's data from one ASP.NET Web page to another. In this page a DataGrid is created and populated from the FAQ popularity stored procedure.

In SendingPage.aspx
181How can I format numbers and date/times using ASP.NET? For example, I want to format a number as a currency.96470222Scott Mitchellmitchell@4guysfromrolla.com1/19/2002 3:12:07 PMASP.NET
161How can I convert a Recordset into an array? Also, how can I convert an array into a Recordset?2380891Scott Mitchellmitchell@4guysfromrolla.com6/14/2001 5:02:02 PMArrays
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?23353021Scott Mitchellmitchell@4guysfromrolla.com1/17/2001 11:38:49 PMDatabases, Errors
83How can I quickly sort a VBScript array? 2300331Richard Lowechadich@yahoo.com11/12/2000 1:58:41 AMArrays
190How do I display data on a web page using arrays instead of Do...While...MoveNext...???...1860061Scott Mitchellmitchell@4guysfromrolla.com4/11/2002 1:14:41 PMArrays
106How can I find out if a record already exists in a database? If it doesn't, I want to add it.18351112Steve Ciminosteve_cimino@hotmail.com12/14/2000 4:59:11 PMDatabases, Queries
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... 1687504Bill Wilkinsonbill@ClearviewDesign.com1/22/2001 5:10:01 PMFileSystemObject
30For session variables to work, must the Web visitor have cookies enabled?1336356Scott Mitchellmitchell@4guysfromrolla.com9/26/2000 11:13:06 PMSession Object
14Can I send emails without using CDONTS?13032210Scott Mitchellmitchell@4guysfromrolla.com9/24/2000 1:18:37 AMEmail
149How can I remove multiple spaces between words in a string? That is, if I have: Hi    there how can I get: Hi there?1295572Scott Mitchellmitchell@4guysfromrolla.com3/31/2001 5:02:54 PMStrings

Source Code
<%@ Page Language="VB" ClassName="SendingPage" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">
  Public ReadOnly Property GridData() As System.Object
      ' Datasource of Datagrid1 is a data table inside a dataset
      Return DataGrid1.DataSource
    End Get
  End Property

  Sub Button_Clicked (sender As Object, e As EventArgs)
  End Sub

  Sub Page_Load(sender As Object, e As EventArgs)
    'bind some relevant data to the grid at page load
  End Sub

  Sub GetData()
    Dim DS As System.Data.DataSet
    Dim Con As System.Data.SqlClient.SqlConnection
    Dim Ada As System.Data.SqlClient.SqlDataAdapter
    Con = New System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings("connectionString"))
    Ada = New System.Data.SqlClient.SqlDataAdapter("sp_Popularity", Con)
    DS = New System.Data.DataSet()
    Ada.Fill(DS, "Table1")
    DataGrid1.DataSource = DS.Tables("Table1").DefaultView
  End Sub

  <form runat="server">
	  <b>In SendingPage.aspx</b><br />
      <asp:datagrid id=DataGrid1 runat=server />

      <asp:Button id="myButton" onClick="Button_Clicked"
            Text="Send Grid Data" runat="server" />

[Return to the article]