teferi2002
Technical User
I am not quite sure what this error msg is and how to fix it. can someone take a look at it give me a suggestion what i should do to take care of it. thanks
The IListSource does not contain any data sources.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The IListSource does not contain any data sources.
Source Error:
Line 19: dgr1.DataSource = oDataSet
Line 20: dgr1.DataMember = "Customers"
Line 21: dgr1.DataBind()
Line 22:
Line 23: End Sub
<%@Page Language="VB" EnableViewState="False" Debug="True" %>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.OleDb" %>
<%-------------------------------------------------------------%>
<script runat="server">
' variable to hold reference to DataSet across routines
Dim oDataSet As DataSet
Sub Page_Load()
'fill the dataset with some rows from database
FillDataSet("c%")
' bind the data to the grid for display
dgr1.DataSource = oDataSet
dgr1.DataMember = "Customers"
dgr1.DataBind()
End Sub
<%-------------------------------------------------------------%>
Sub FillDataSet(sCustID As String)
' get DataSet with rows from Northwind tables
Dim sCustSql As String _
= "SELECT CustomerID, CompanyName, City, Country " _
& "FROM Customers WHERE CustomerID LIKE '" & sCustID & "'"
Dim sOrdersSql As String _
= "SELECT CustomerID, OrderID, OrderDate FROM Orders " _
& "WHERE CustomerID LIKE '" & sCustID & "'"
Dim sDetailsSql As String _
= "SELECT [Order Details].OrderID, Products.ProductID, " _
& "Products.ProductName, [Order Details].Quantity, " _
& "[Order Details].UnitPrice " _
& "FROM [Order Details] JOIN Products " _
& "ON [Order Details].ProductID = Products.ProductID " _
& "WHERE [Order Details].OrderID IN " _
& " (SELECT OrderID FROM Orders " _
& " WHERE CustomerID LIKE '" & sCustID & "')"
Dim sConnect As New OleDbConnection("provider=Microsoft.jet.OleDb.4.0;Data Source=c:\Nwind.mdb" )
oDataSet = New DataSet()
Try
' fill DataSet with three tables
Dim oDA As New OleDbDataAdapter(sCustSQL, sConnect)
sConnect.Open()
oDA.Fill(oDataSet, "Customers")
oDA.SelectCommand.CommandText = sOrdersSql
oDA.Fill(oDataSet, "Orders")
oDA.SelectCommand.CommandText = sDetailsSql
oDA.Fill(oDataSet, "OrderDetails")
sConnect.Close()
' create relations between the tables
Dim oRel As New DataRelation("CustOrders", _
oDataSet.Tables("Customers").Columns("CustomerID"), _
oDataSet.Tables("Orders").Columns("CustomerID"))
oDataSet.Relations.Add(oRel)
oRel = New DataRelation("OrdersODetails", _
oDataSet.Tables("Orders").Columns("OrderID"), _
oDataSet.Tables("OrderDetails").Columns("OrderID"))
oDataSet.Relations.Add(oRel)
Catch oErr As Exception
' be sure to close connection if error occurs
If sConnect.State <> ConnectionState.Closed Then
sConnect.Close()
End If
' display error message in page
lblErr.Text = oErr.Message
End Try
End Sub
</script>
<%-------------------------------------------------------------%>
<%-------------------------------------------------------------%>
<html>
<head>
<title>Declarative Nested Binding to a DataSet</title>
</head>
<body>
<span class="heading">Declarative Nested Binding to a DataSet</span><hr />
<form runat="server">
<asp:Label id="lblErr" EnableViewState="False" runat="server" /><p />
<asp
ataGrid id="dgr1" runat="server"
Font-Size="10" Font-Name="Tahoma,Arial,Helvetica,sans-serif"
BorderStyle="None" BorderWidth="1px" BorderColor="#deba84"
BackColor="#DEBA84" CellPadding="5" CellSpacing="1"
AutoGenerateColumns="False"
>
<HeaderStyle Font-Bold="True" ForeColor="#ffffff" BackColor="#b50055" />
<ItemStyle BackColor="#FFF7E7" VerticalAlign="Top" />
<AlternatingItemStyle backcolor="#ffffc0" />
<Columns>
<asp:TemplateColumn HeaderText="Customer Details">
<ItemTemplate>
<b><%# Container.DataItem("CompanyName") %></b><br />
City: <%# Container.DataItem("City") %><br />
Country: <%# Container.DataItem("Country") %><br />
CustomerID: "<%# Container.DataItem("CustomerID") %>"
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Order History">
<ItemTemplate>
<asp
ataGrid id="dgr2" runat="server"
BorderStyle="None" BorderWidth="0" BackColor="#deba84"
CellPadding="5" CellSpacing="2" Width="100%"
AutoGenerateColumns="False"
DataSource='<%# CType(Container.DataItem,DataRowView).CreateChildView("CustOrders") %>'
>
<HeaderStyle BackColor="#c0c0c0" />
<ItemStyle Font-Bold="True" VerticalAlign="Top" />
<Columns>
<asp:BoundColumn DataField="OrderID" HeaderText="Number" />
<asp:TemplateColumn HeaderText="Details">
<ItemTemplate>
<asp:Label runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, _
"OrderDate", "{0:dddd dd MMM yyyy}") %>' />
<asp
ataGrid id="dgr3" runat="server"
BorderStyle="None" BorderWidth="0"
CellPadding="3" CellSpacing="0" Width="100%"
AutoGenerateColumns="False"
DataSource='<%# CType(Container.DataItem,DataRowView).CreateChildView("OrdersODetails") %>'
>
<HeaderStyle BackColor="#c0c0c0" />
<Columns>
<asp:BoundColumn DataField="ProductID"
HeaderText="ID" />
<asp:BoundColumn DataField="ProductName"
HeaderText="Product" />
<asp:BoundColumn DataField="Quantity"
ItemStyle-HorizontalAlign="Right"
HeaderStyle-HorizontalAlign="Right"
HeaderText="Qty" />
<asp:BoundColumn DataField="UnitPrice"
DataFormatString="${0:f2}"
ItemStyle-HorizontalAlign="Right"
HeaderStyle-HorizontalAlign="Right"
HeaderText="Price"/>
</Columns>
</asp
ataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp
ataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp
ataGrid>
</form>
<span class="cite">
Remember to edit the connection strings in your web.config
file for the Northwind sample database.
</span>
<hr />
</body>
</html>
The IListSource does not contain any data sources.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The IListSource does not contain any data sources.
Source Error:
Line 19: dgr1.DataSource = oDataSet
Line 20: dgr1.DataMember = "Customers"
Line 21: dgr1.DataBind()
Line 22:
Line 23: End Sub
<%@Page Language="VB" EnableViewState="False" Debug="True" %>
<%@Import Namespace="System.Data" %>
<%@Import Namespace="System.Data.OleDb" %>
<%-------------------------------------------------------------%>
<script runat="server">
' variable to hold reference to DataSet across routines
Dim oDataSet As DataSet
Sub Page_Load()
'fill the dataset with some rows from database
FillDataSet("c%")
' bind the data to the grid for display
dgr1.DataSource = oDataSet
dgr1.DataMember = "Customers"
dgr1.DataBind()
End Sub
<%-------------------------------------------------------------%>
Sub FillDataSet(sCustID As String)
' get DataSet with rows from Northwind tables
Dim sCustSql As String _
= "SELECT CustomerID, CompanyName, City, Country " _
& "FROM Customers WHERE CustomerID LIKE '" & sCustID & "'"
Dim sOrdersSql As String _
= "SELECT CustomerID, OrderID, OrderDate FROM Orders " _
& "WHERE CustomerID LIKE '" & sCustID & "'"
Dim sDetailsSql As String _
= "SELECT [Order Details].OrderID, Products.ProductID, " _
& "Products.ProductName, [Order Details].Quantity, " _
& "[Order Details].UnitPrice " _
& "FROM [Order Details] JOIN Products " _
& "ON [Order Details].ProductID = Products.ProductID " _
& "WHERE [Order Details].OrderID IN " _
& " (SELECT OrderID FROM Orders " _
& " WHERE CustomerID LIKE '" & sCustID & "')"
Dim sConnect As New OleDbConnection("provider=Microsoft.jet.OleDb.4.0;Data Source=c:\Nwind.mdb" )
oDataSet = New DataSet()
Try
' fill DataSet with three tables
Dim oDA As New OleDbDataAdapter(sCustSQL, sConnect)
sConnect.Open()
oDA.Fill(oDataSet, "Customers")
oDA.SelectCommand.CommandText = sOrdersSql
oDA.Fill(oDataSet, "Orders")
oDA.SelectCommand.CommandText = sDetailsSql
oDA.Fill(oDataSet, "OrderDetails")
sConnect.Close()
' create relations between the tables
Dim oRel As New DataRelation("CustOrders", _
oDataSet.Tables("Customers").Columns("CustomerID"), _
oDataSet.Tables("Orders").Columns("CustomerID"))
oDataSet.Relations.Add(oRel)
oRel = New DataRelation("OrdersODetails", _
oDataSet.Tables("Orders").Columns("OrderID"), _
oDataSet.Tables("OrderDetails").Columns("OrderID"))
oDataSet.Relations.Add(oRel)
Catch oErr As Exception
' be sure to close connection if error occurs
If sConnect.State <> ConnectionState.Closed Then
sConnect.Close()
End If
' display error message in page
lblErr.Text = oErr.Message
End Try
End Sub
</script>
<%-------------------------------------------------------------%>
<%-------------------------------------------------------------%>
<html>
<head>
<title>Declarative Nested Binding to a DataSet</title>
</head>
<body>
<span class="heading">Declarative Nested Binding to a DataSet</span><hr />
<form runat="server">
<asp:Label id="lblErr" EnableViewState="False" runat="server" /><p />
<asp
Font-Size="10" Font-Name="Tahoma,Arial,Helvetica,sans-serif"
BorderStyle="None" BorderWidth="1px" BorderColor="#deba84"
BackColor="#DEBA84" CellPadding="5" CellSpacing="1"
AutoGenerateColumns="False"
>
<HeaderStyle Font-Bold="True" ForeColor="#ffffff" BackColor="#b50055" />
<ItemStyle BackColor="#FFF7E7" VerticalAlign="Top" />
<AlternatingItemStyle backcolor="#ffffc0" />
<Columns>
<asp:TemplateColumn HeaderText="Customer Details">
<ItemTemplate>
<b><%# Container.DataItem("CompanyName") %></b><br />
City: <%# Container.DataItem("City") %><br />
Country: <%# Container.DataItem("Country") %><br />
CustomerID: "<%# Container.DataItem("CustomerID") %>"
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="Order History">
<ItemTemplate>
<asp
BorderStyle="None" BorderWidth="0" BackColor="#deba84"
CellPadding="5" CellSpacing="2" Width="100%"
AutoGenerateColumns="False"
DataSource='<%# CType(Container.DataItem,DataRowView).CreateChildView("CustOrders") %>'
>
<HeaderStyle BackColor="#c0c0c0" />
<ItemStyle Font-Bold="True" VerticalAlign="Top" />
<Columns>
<asp:BoundColumn DataField="OrderID" HeaderText="Number" />
<asp:TemplateColumn HeaderText="Details">
<ItemTemplate>
<asp:Label runat="server"
Text='<%# DataBinder.Eval(Container.DataItem, _
"OrderDate", "{0:dddd dd MMM yyyy}") %>' />
<asp
BorderStyle="None" BorderWidth="0"
CellPadding="3" CellSpacing="0" Width="100%"
AutoGenerateColumns="False"
DataSource='<%# CType(Container.DataItem,DataRowView).CreateChildView("OrdersODetails") %>'
>
<HeaderStyle BackColor="#c0c0c0" />
<Columns>
<asp:BoundColumn DataField="ProductID"
HeaderText="ID" />
<asp:BoundColumn DataField="ProductName"
HeaderText="Product" />
<asp:BoundColumn DataField="Quantity"
ItemStyle-HorizontalAlign="Right"
HeaderStyle-HorizontalAlign="Right"
HeaderText="Qty" />
<asp:BoundColumn DataField="UnitPrice"
DataFormatString="${0:f2}"
ItemStyle-HorizontalAlign="Right"
HeaderStyle-HorizontalAlign="Right"
HeaderText="Price"/>
</Columns>
</asp
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp
</form>
<span class="cite">
Remember to edit the connection strings in your web.config
file for the Northwind sample database.
</span>
<hr />
</body>
</html>