ASP.Net Tutorials

Display SQL records with a data grid, with custom headers

my_quotes.aspx

<%@ import namespace="system.data.sqlClient" %>
<script runat="server">
sub page_load
dim myConnection as sqlConnection
dim myRecordSelect as sqlCommand
myConnection = new sqlConnection("SERVER=xxxxxxxx; UID=xxxxxxxx; PWD=xxxxxxxx; DATABASE=xxxxxxxx" )
myRecordSelect = new sqlCommand("SELECT TOP 3 * FROM my_quotes", myConnection )
myConnection.open()
myRecords.dataSource = myRecordSelect.ExecuteReader()
myRecords.dataBind()
myConnection.close()
end Sub
</script>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Display records with a data Grid</title>
</head>

<body>

<asp:dataGrid
id=
"myRecords"
autoGenerateColumns="false"
enableViewState="false"
headerStyle-BackColor="#f0f0f0f0"
borderColor="#ffffff"
cellPadding="4"
cellSpacing="1"
font-name="Arial"
font-size="10pt"
runat="server">

<columns>
<asp:boundColumn dataField="quote" headerText="QUOTE"/>
<asp:boundColumn dataField="first_name" headerText="FIRST NAME" />
<asp:boundColumn dataField="last_name" headerText="LAST NAME" />
</columns>

</asp:DataGrid>

</body>
</html>

My Quotes - demo
QUOTEFIRST NAMELAST NAME
I am beginning to suspect all elaborate and special systems of education. They seem to me to be built up on the supposition that every child is a kind of idiot who must be taught to think.AnneSullivan
Creativity is a type of learning process where the teacher and pupil are located in the same individual.ArthurKoestler
Education is a better safeguard of liberty than a standing army.EdwardEverett
ASP.Net
Other Tutorials