Display column alias in asp datagrid : Column Alias « ADO.net Database « ASP.Net






Display column alias in asp datagrid

<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    Dim DBConn as OleDbConnection
    Dim DBCommand As OleDbDataAdapter
    Dim DSPageData as New DataSet
    DBConn = New OleDbConnection( _
        "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
        & "DATA SOURCE=" _
        & Server.MapPath _
        ("ProductsDB.mdb;"))
    DBCommand = New OleDbDataAdapter _
        ("Select ProductName as [Name], " _
        & "ProductDescription as [Description], Price " _
        & "From Products Where " _
        & "Datediff(""d"",DateAdded,Now) <= 31 " _
        & "Order by ProductName", DBConn)
    DBCommand.Fill(DSPageData, _
        "NewProducts")
    dgNewProducts.DataSource = _
        DSPageData.Tables("NewProducts").DefaultView
    dgNewProducts.DataBind()
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>New Products</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<BR><BR>
<asp:label 
    id="lblMessage1" 
    font-size="12pt"
    font-bold="True"
    font-name="Lucida Console"
    text="New Products added during the past month!"
    runat="server"
/>
<BR><BR>
<asp:datagrid
    id="dgNewProducts" 
    runat="server" 
    autogeneratecolumns="True"
/>
</form>
</BODY>
</HTML>           
       








Related examples in the same category