Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / January 2005

Tip: Looking for answers? Try searching our database.

Datagrid within a Datagrid, treeview style....

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Roy - 13 Jan 2005 04:21 GMT
Hey all,
As the subject suggests, that's what I'm trying to accomplish.
I'd trying to design something akin to this:

->First_Name | Last_Name | blah1 | blah2 | blah3
--->X | Y | Z
--->X | Y | Z
--->X | Y | Z

First name and last name combined would be the key for the parent table
that would be the link to the child table which would display the rows
of "xyz" information. As an added twist, I'm trying to make the child
records editable. :) I'm not a newcomer to programming as I've been in
the industry for a couple years, but this is my first exposure to .NET
and web development, so I'm still very much a newbie in this arena...

Anyone have any links or better yet, source code that they could post?
Thanks much!
-R
R. Thomas, aka Xtreme.Net - 13 Jan 2005 04:59 GMT
Why dont you opt for 3rd pary controls?

> Hey all,
> As the subject suggests, that's what I'm trying to accomplish.
[quoted text clipped - 15 lines]
> Thanks much!
> -R
Roy - 13 Jan 2005 14:14 GMT
My company does not have VS .net, therefore, I can't import 3rd party
treeview web controls. I'm doing everything by hand... :/
Ken Cox [Microsoft MVP] - 13 Jan 2005 22:25 GMT
The source code here would probably give you a good start at that:

http://www.denisbauer.com/ASPNETControls/HierarGrid.aspx

> Hey all,
> As the subject suggests, that's what I'm trying to accomplish.
[quoted text clipped - 15 lines]
> Thanks much!
> -R
Roy - 14 Jan 2005 02:40 GMT
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:DataGrid 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:DataGrid>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</asp:datagrid>
   </form>
</body>
</html
R. Thomas, aka Xtreme.Net - 14 Jan 2005 08:21 GMT
Here is the datagrid code that you need...
http://www.codeproject.com/useritems/DataGridEmbededDataGrid.asp
P.s : If this post was helpful, please click 'Yes' on the top of this post
to close this thread. Thanks
HTHs...
R. Thomas

> 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
[quoted text clipped - 92 lines]
> </body>
> </html
Roy - 14 Jan 2005 13:43 GMT
While I appreciate the reply RT, the link wasn't particularly helpful.
:(
It was written in C# (and I must use VB) and unless I'm
misunderstanding something, it's not anything different from what I
already have...

Question: will an inner datagrid *always* pull from the outergrid's
datasource? My code (by my eyes) seems to be telling the inner grid to
pull from a separate table, yet that is simply not occuring. Where am I
going wrong?
Ken Cox [Microsoft MVP] - 14 Jan 2005 14:09 GMT
> P.s : If this post was helpful, please click 'Yes' on the top of this post
> to close this thread. Thanks

What 'Yes' are you referring to? These are widely distributed Usenet
messages. You can't count on the user seeing a proprietary interface to
"close" a thread.

Your best bet would be to post directly in msnews.microsoft.com's groups.
Roy - 14 Jan 2005 14:55 GMT
Aye, no "Yes" appears using Outlook's newsreader or google groups site.
Anyone else have helpful info on nested, editable grids?
R. Thomas, aka Xtreme.Net - 14 Jan 2005 17:25 GMT
The link that I provided you was in C#, so what? does it take a huge effort
to convert it to VB?
That is an article about editable datagrid, which is very near to what you
need...
If you need everything to be done, I suggest you go for 3rd party controls
R. Thomas

> Aye, no "Yes" appears using Outlook's newsreader or google groups site.
> Anyone else have helpful info on nested, editable grids?
Roy - 14 Jan 2005 19:31 GMT
Again, I appreciate the comment, but (and correct me if I'm wrong) the
link provides no new information. I seem to be using the exact same
process that the article describes. My code is clearly in error
somewhere, but I seem unable to isolate the error. One more time:

In my code above the inner grid appears to be incapable of pulling data
from the database itself. It attempts to pull it's data from the outer
grids datasource. How can I fix this? Does anyone know?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.