ASP.Net Tutorials

Display records from an SQL database with a data grid, with auto columns disabled

display_records_with_a_data_grid.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" runat="server">

<columns>

<asp:boundColumn dataField="quote" />
<asp:boundColumn dataField="first_name" />
<asp:boundColumn dataField="last_name" />

</columns>

</asp:dataGrid>

</body>
</html>

Display records with a data grid, with auto columns disabled
   
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