Make treeview like datagrid

G

Guest

I want to display some drill-down data with a datagrid look. I can get the
exact functionality I want with a treeview, but I don't like the way the
treeview looks and formats the data. I want a multi-column table look like a
datagrid. It is not as easy as just hardcoding a datagrid within a datagrid
because the data may do down pretty deep. The treeview works great for this.
Is there a way to make the treeview look kind of like a datagrid or
something? Thanks.
 
E

Edwin Knoppert

If the TV knows itemtemplates, than this is the magic word.
Add an item template and add a label control in that.
Set label text to"anything"
Then goto the 'html' source and modify this text propery for this label
with:

(From head:)
Text='<%#Eval("Fieldname1" ) & Eval("Fieldname2" ) %>'

Something like that.
This is just a start of course, you can swap the label for a table etc..
 
E

Edwin Knoppert

Note, you should change Fieldname1 etc.. for the real fieldname.
I'm curious myself, will do a test tomorrow.
 
G

Guest

The Treeview does not have itemtemplates.

Edwin Knoppert said:
If the TV knows itemtemplates, than this is the magic word.
Add an item template and add a label control in that.
Set label text to"anything"
Then goto the 'html' source and modify this text propery for this label
with:

(From head:)
Text='<%#Eval("Fieldname1" ) & Eval("Fieldname2" ) %>'

Something like that.
This is just a start of course, you can swap the label for a table etc..
 
E

Edwin Knoppert

Yes, i just noticed.
So i tried a different but more harder approach:

<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs)
End Sub

Protected Sub TreeView1_TreeNodePopulate(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.TreeNodeEventArgs)
e.Node.Text = Now & "<BR>" & Now.TimeOfDay.ToString
End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TreeView ID="TreeView1" runat="server"
OnTreeNodePopulate="TreeView1_TreeNodePopulate">
<Nodes>
</asp:TreeNode>
</asp:TreeNode>
</Nodes>
</asp:TreeView>
&nbsp;</div>
</form>
</body>
</html>

Maybe you can dump a table look-alike in during each node's event?
Let me know, i'm curious about this.

Edwin,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top