|
|
|
|
Choose a table
|
Note when you choose a query, query script is also created
|
when you are using for the first time you, may opt this option "test
connection" |
Caution: your database could be huge, "*" wild cat may not be an ideal
option to use. |
You may not able tot browse the folder
|
http://manas8x/my_aspnet/aspnet_controls/aspnet_datasource_lib/data_accsess.aspx
|
To view the data we need a container
|
|
Note: before you run: this example is to show you the use of this
control, caution with the size of the data base you are using, it may choke
your site.
|
Code behind Listview
<asp:AccessDataSource runat="server" id="AccessDataSource1" DataFile="C:\my_aspnet\aspnet_controls\aspnet_datasource_lib\winepro2007.mdb"
SelectCommand="SELECT * FROM [WineProposal]">
</asp:AccessDataSource>
<asp:DataList runat="server" id="DataList1" DataSourceID="AccessDataSource1">
<ItemTemplate>
BottleSize:
<asp:Label Text='<%# Eval("BottleSize") %>' runat="server" id="BottleSizeLabel"
/>
<br />
Producer:
<asp:Label Text='<%# Eval("Producer") %>' runat="server" id="ProducerLabel"
/>
<br />
LabelName:
<asp:Label Text='<%# Eval("LabelName") %>' runat="server" id="LabelNameLabel"
/>
<br />
Varietal:
<asp:Label Text='<%# Eval("Varietal") %>' runat="server" id="VarietalLabel"
/>
<br />
Prolavar:
<asp:Label Text='<%# Eval("Prolavar") %>' runat="server" id="ProlavarLabel"
/>
<br />
Appellation:
<asp:Label Text='<%# Eval("Appellation") %>' runat="server" id="AppellationLabel"
/>
<br />
AVA_Zone:
<asp:Label Text='<%# Eval("AVA_Zone") %>' runat="server" id="AVA_ZoneLabel"
/>
<br />
APP_AVA:
<asp:Label Text='<%# Eval("APP_AVA") %>' runat="server" id="APP_AVALabel"
/>
<br />
ItemNO:
<asp:Label Text='<%# Eval("ItemNO") %>' runat="server" id="ItemNOLabel" />
<br />
Inventory:
<asp:Label Text='<%# Eval("Inventory") %>' runat="server" id="InventoryLabel"
/>
<br />
Reserve:
<asp:Label Text='<%# Eval("Reserve") %>' runat="server" id="ReserveLabel"
/>
<br />
Supplier:
<asp:Label Text='<%# Eval("Supplier") %>' runat="server" id="SupplierLabel"
/>
<br />
Specialty:
<asp:Label Text='<%# Eval("Specialty") %>' runat="server" id="SpecialtyLabel"
/>
<br />
Type:
<asp:Label Text='<%# Eval("Type") %>' runat="server" id="TypeLabel" />
<br />
Country:
<asp:Label Text='<%# Eval("Country") %>' runat="server" id="CountryLabel"
/>
<br />
Vintage:
<asp:Label Text='<%# Eval("Vintage") %>' runat="server" id="VintageLabel"
/>
<br />
S_Status:
<asp:Label Text='<%# Eval("S_Status") %>' runat="server" id="S_StatusLabel"
/>
<br />
BPC:
<asp:Label Text='<%# Eval("BPC") %>' runat="server" id="BPCLabel" />
<br />
Cases:
<asp:Label Text='<%# Eval("Cases") %>' runat="server" id="CasesLabel" />
<br />
Deal No:
<asp:Label Text='<%# Eval("[Deal No]") %>' runat="server" id="Deal_NoLabel"
/>
<br />
List:
<asp:Label Text='<%# Eval("List") %>' runat="server" id="ListLabel" />
<br />
Discount:
<asp:Label Text='<%# Eval("Discount") %>' runat="server" id="DiscountLabel"
/>
<br />
NetCase:
<asp:Label Text='<%# Eval("NetCase") %>' runat="server" id="NetCaseLabel"
/>
<br />
Netbottle:
<asp:Label Text='<%# Eval("Netbottle") %>' runat="server" id="NetbottleLabel"
/>
<br />
OzCost:
<asp:Label Text='<%# Eval("OzCost") %>' runat="server" id="OzCostLabel" />
<br />
<br />
</ItemTemplate>
</asp:DataList>
|
The datasource holds the string for the connection, while listview
displays the field contents during the run time
- Datasource:
- <asp:AccessDataSource runat="server"
id="AccessDataSource1" DataFile="C:\my_aspnet\aspnet_controls\aspnet_datasource_lib\winepro2007.mdb"
SelectCommand="SELECT * FROM [WineProposal]">
</asp:AccessDataSource>
- List View
- <asp:DataList runat="server" id="DataList1" DataSourceID="AccessDataSource1">
<ItemTemplate>
BottleSize:
<asp:Label Text='<%# Eval("BottleSize") %>' runat="server" id="BottleSizeLabel"
/>
<br />
Producer:
<asp:Label Text='<%# Eval("Producer") %>' runat="server" id="ProducerLabel"
/>
<br />
..............................
- <br />
</ItemTemplate>
</asp:DataList>
All the codes to display overall data structure are contained
in a form
|
Complete Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Page Language="C#" %>
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>data access with asp net controls</title>
</head>
<body style="color: #000080; background-color: #FCEFBC">
<form id="form1" runat="server">
<asp:AccessDataSource runat="server" id="AccessDataSource1" DataFile="C:\my_aspnet\aspnet_controls\aspnet_datasource_lib\winepro2007.mdb"
SelectCommand="SELECT * FROM [WineProposal]">
</asp:AccessDataSource>
<asp:DataList runat="server" id="DataList1" DataSourceID="AccessDataSource1">
<ItemTemplate>
BottleSize:
<asp:Label Text='<%# Eval("BottleSize") %>' runat="server" id="BottleSizeLabel"
/>
<br />
Producer:
<asp:Label Text='<%# Eval("Producer") %>' runat="server" id="ProducerLabel"
/>
<br />
LabelName:
<asp:Label Text='<%# Eval("LabelName") %>' runat="server" id="LabelNameLabel"
/>
<br />
Varietal:
<asp:Label Text='<%# Eval("Varietal") %>' runat="server" id="VarietalLabel"
/>
<br />
Prolavar:
<asp:Label Text='<%# Eval("Prolavar") %>' runat="server" id="ProlavarLabel"
/>
<br />
Appellation:
<asp:Label Text='<%# Eval("Appellation") %>' runat="server" id="AppellationLabel"
/>
<br />
AVA_Zone:
<asp:Label Text='<%# Eval("AVA_Zone") %>' runat="server" id="AVA_ZoneLabel"
/>
<br />
APP_AVA:
<asp:Label Text='<%# Eval("APP_AVA") %>' runat="server" id="APP_AVALabel"
/>
<br />
ItemNO:
<asp:Label Text='<%# Eval("ItemNO") %>' runat="server" id="ItemNOLabel" />
<br />
Inventory:
<asp:Label Text='<%# Eval("Inventory") %>' runat="server" id="InventoryLabel"
/>
<br />
Reserve:
<asp:Label Text='<%# Eval("Reserve") %>' runat="server" id="ReserveLabel"
/>
<br />
Supplier:
<asp:Label Text='<%# Eval("Supplier") %>' runat="server" id="SupplierLabel"
/>
<br />
Specialty:
<asp:Label Text='<%# Eval("Specialty") %>' runat="server" id="SpecialtyLabel"
/>
<br />
Type:
<asp:Label Text='<%# Eval("Type") %>' runat="server" id="TypeLabel" />
<br />
Country:
<asp:Label Text='<%# Eval("Country") %>' runat="server" id="CountryLabel"
/>
<br />
Vintage:
<asp:Label Text='<%# Eval("Vintage") %>' runat="server" id="VintageLabel"
/>
<br />
S_Status:
<asp:Label Text='<%# Eval("S_Status") %>' runat="server" id="S_StatusLabel"
/>
<br />
BPC:
<asp:Label Text='<%# Eval("BPC") %>' runat="server" id="BPCLabel" />
<br />
Cases:
<asp:Label Text='<%# Eval("Cases") %>' runat="server" id="CasesLabel" />
<br />
Deal No:
<asp:Label Text='<%# Eval("[Deal No]") %>' runat="server" id="Deal_NoLabel"
/>
<br />
List:
<asp:Label Text='<%# Eval("List") %>' runat="server" id="ListLabel" />
<br />
Discount:
<asp:Label Text='<%# Eval("Discount") %>' runat="server" id="DiscountLabel"
/>
<br />
NetCase:
<asp:Label Text='<%# Eval("NetCase") %>' runat="server" id="NetCaseLabel"
/>
<br />
Netbottle:
<asp:Label Text='<%# Eval("Netbottle") %>' runat="server" id="NetbottleLabel"
/>
<br />
OzCost:
<asp:Label Text='<%# Eval("OzCost") %>' runat="server" id="OzCostLabel" />
<br />
<br />
</ItemTemplate>
</asp:DataList>
</form>
</body>
</html>
|
|
|
|