Thanks! Anyone bored and care to troubleshoot this for me? Herein lies
my problem, my inner datagrid is ... well it seems to be looking at my
outer datagrid's datasource? How can I get around this? The error is:
"A field or property with the name 'ocean_carrier_cd' was not found on
the selected data source." Simple enough, right? Well, the column does
exist within the database, so something is clearly missing here. On
closer examination the error specificly points to line 8 below:
"Line 6: Sub Page_Load(sender as system.object, e as
system.eventargs)
Line 7: dgMaster.DataSource = GetPOE()
Line 8: dgMaster.DataBind()
Line 9: End Sub"
....line 8 is a reference to the outer datagrid. Does anyone have any
idea how to get the inner datagrid to talk to the database w/o going
through the outer grid? I'm including my full code listing for
posterity purposes (and of course so that you gurus could peruse it).
You'd be surprised how hard it is to find anything online regarding a
datagrid within a datagrid without using VS.NET.
**********************************************************8
<%@ Page Language="VB" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">
Sub Page_Load(sender as system.object, e as system.eventargs)
dgMaster.DataSource = GetPOE()
dgMaster.DataBind()
End Sub
Function GetPOE() As DataTable
Dim ds As New DataSet()
Dim conn As New
SqlConnection("server=localhost;uid=itv;pwd=itv_$ql!;database=maersk_test")
Dim strSQL As String
strSQL = "SELECT voydoc, poe FROM LLA ORDER BY voydoc"
Dim da As New SqlDataAdapter(strSQL, conn)
da.Fill(ds, "lla")
Return ds.Tables("lla")
End Function
Function GetDetails(ByVal x As Object, ByVal y as Object)
Dim conn As New
SqlConnection("server=localhost;uid=itv;pwd=itv_$ql!;database=maersk_test")
Dim strSQL As String
Dim ds As New DataSet()
strSQL = "SELECT IsNull(firstvd.ocean_carrier_cd, ''),
IsNull(firstvd.carrier_booking_nr, ''),IsNull(firstvd.equipment, '') "
strSQL &= "FROM firstvd INNER JOIN "
strSQL &= "lla ON firstvd.voydoc + firstvd.poe = lla.voydoc +
lla.poe "
strSQL &= "WHERE firstvd.voydoc = '"& x.tostring &"' AND
firstvd.poe = '"& y.tostring &"'"
Dim da As New SqlDataAdapter(strSQL, conn)
da.Fill(ds, "firstvd")
Return ds.Tables("firstvd")
End Function
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:datagrid id="dgMaster" runat="server"
autogeneratecolumns="False">
<Columns>
<asp:BoundColumn DataField="voydoc"
HeaderText="VoyDoc"></asp:BoundColumn>
<asp:TemplateColumn HeaderText="Column2">
<ItemTemplate>
<asp
ataGrid runat="server" id="dgDetails"
AutoGenerateColumns="False" DataSource=<%#
GetDetails(container.dataitem("voydoc"),container.dataitem("poe"))%> >
<Columns>
<asp:BoundColumn
DataField="ocean_carrier_cd" HeaderText="Carrier"></asp:BoundColumn>
<asp:BoundColumn
DataField="carrier_booking_nr" HeaderText="Booking
#"></asp:BoundColumn>
<asp:BoundColumn DataField="Equipment"
HeaderText="Equipment"></asp:BoundColumn>
</Columns>
</asp
ataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
</form>
</body>
</html>