Main Menu

HOME

.Net
ASP
Assembly
C
C++
Delphi
HTML
Java
JavaScript
MySQL
PC interface
Powershell
Perl
PHP
VBScript
Visual Basic
XML

Make money selling software. Check this out here

Hosted clickbank mall. Check this out here




   Misc

   Amazon

   Links

    


Datalist control example

 

This example is similar to our datalist example but shows various properties in action

You can see it in action here


 

 

<%@ Import Namespace="System.Data.OleDb" %>

<script runat="server">
sub Page_Load
'variable declarations
dim dbconnection,sqlstring,dbcommand,dbreader
'connect to our database
dbconnection=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & server.mappath("sampledb.mdb"))
'open a connection
dbconnection.Open()
'This is our sql, in this case select all items from the tblsample table
sqlstring="SELECT * FROM tblsample"
dbcommand=New OleDbCommand(sqlstring,dbconnection)
dbreader=dbcommand.ExecuteReader()
tblsample.DataSource=dbreader
tblsample.DataBind()
'close connection and reader objects
dbreader.Close()
dbconnection.Close()
end sub
</script>

<html>
<body>

<asp:Datalist id="tblsample" runat="server"
cellpadding="2"
cellspacing="2"
borderstyle="inset"
backcolor="green"
width="100%"
headerstyle-font-name="Arial"
headerstyle-font-size="10pt"
headerstyle-horizontalalign="left"
headerstyle-font-bold="True"
itemstyle-backcolor="yellow"
itemstyle-forecolor="black"
footerstyle-font-size="9pt"
footerstyle-font-italic="True">
<HeaderTemplate>
URLS
</HeaderTemplate>

<ItemTemplate>
<%#Container.DataItem("url")%>
</ItemTemplate>

<FooterTemplate>
This is our sample database
</FooterTemplate>

</asp:Datalist>

</body>
</html>



 




   Sponsors
 

   Software
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals

   Source Code
str_replace example(php)
video memory information(Darkbasic)
Datediff example(ASP)
while loop example(Java)
Launch format dialog box(VB)
use a process to open a fie in notepad(VB.net)
IPaddress(VB)
uppercase letters(CSS)

    




Copyright © 2004 by programmershelp.co.uk