471,319 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,319 software developers and data experts.

How to enter a variable in the treenodesrc of a treenode

Hi. I am trying to enter a variable in the treenodesrc of a treenode. I am
basically trying to send an ID variable into sql to return different records.
I've searched everywhere and cannot find the answer. I'd appreciate and help.
Thanks.

What I'm doing is creating a treeview with the structure as follows (this is
the expanded view):

- Item Status
- Item Status Details
- Item Status Details
- Item Status Details

It's very basic. "Item Status" is the static <treenode text=. Now the
treenodesrc is where I'm having my problem. I'm trying to send a dynamic
variable into sql in order to return the associated records ("Item Status
Details") using --
TreeNodeSrc="http://www.domain.com/sqlDataBaseName?sql=execute+StoredProcedu
reName+@variable=&variable". The variable comes to the page through a
querystring. Of course my code reflects my specifics. But I've set up
XMLSQL, and when I hard code the variable into the string it works perfectly.
The query works, my stored procedure returns the proper XML, and my TreeView
looks exactly how I want it to look. But when I try to put a dynamic variable
in I get a Parser Error and says "The literal string - and then my
treenodesrc string - was found. Literal strings are not allowed within this
control.

All that I'm trying to do is send a dynamic variable into that treenodesrc
string where that &variable is above.

Hopefully I've explained this well enough. Let me know.

Thanks.

Nov 19 '05 #1
3 1717
Hi markaelkins,

Welcome to ASPNET newsgroup.
From your description, you're using the IE WEbcontrols's TreeView control
and use some dynamically retrieved xmldata from sqlserver to bind the nodes
in TreeView. Currently you're wondering how to dynamically assign the
TreeNodeSrc for certain TreeNodes in the TreeView, yes?

Based on my research, for the IE TreeView control, in the aspx inline
template, we can not use
<% ...%> render expression(also not allowed for assigning value to normal
webserver control's property) or
<%# ...%> databinding expression to assign dynamic value to TreeNode's
property. However, we can use code in codebehind or help function to
assign the property on the TreeNode instance and call its DataBind() method
to populate the dynamic children. For example:

===============
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{

tvMain.Nodes[0].TreeNodeSrc = GetNodeSrcFromDataBase();
tvMain.Nodes[0].Databind();

}
}

The TreeView has provide some function like TreeView.GetNodeFromIndex which
help use find node instance
through Node hierarchy.

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: How to enter a variable in the treenodesrc of a treenode
| thread-index: AcW6AvT5x6w5gCYGTfWxLqsYXqsBLA==
| X-WBNR-Posting-Host: 67.79.167.182
| From: "=?Utf-8?B?bWFya2FlbGtpbnNAbmV3c2dyb3Vwcy5ub3NwYW0=?="
<ma*********@newsgroups.nospam>
| Subject: How to enter a variable in the treenodesrc of a treenode
| Date: Thu, 15 Sep 2005 07:37:11 -0700
| Lines: 34
| Message-ID: <2A**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:124805
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi. I am trying to enter a variable in the treenodesrc of a treenode. I
am
| basically trying to send an ID variable into sql to return different
records.
| I've searched everywhere and cannot find the answer. I'd appreciate and
help.
| Thanks.
|
| What I'm doing is creating a treeview with the structure as follows (this
is
| the expanded view):
|
| - Item Status
| - Item Status Details
| - Item Status Details
| - Item Status Details
|
| It's very basic. "Item Status" is the static <treenode text=. Now the
| treenodesrc is where I'm having my problem. I'm trying to send a dynamic
| variable into sql in order to return the associated records ("Item Status
| Details") using --
|
TreeNodeSrc="http://www.domain.com/sqlDataBaseName?sql=execute+StoredProcedu
| reName+@variable=&variable". The variable comes to the page through a
| querystring. Of course my code reflects my specifics. But I've set up
| XMLSQL, and when I hard code the variable into the string it works
perfectly.
| The query works, my stored procedure returns the proper XML, and my
TreeView
| looks exactly how I want it to look. But when I try to put a dynamic
variable
| in I get a Parser Error and says "The literal string - and then my
| treenodesrc string - was found. Literal strings are not allowed within
this
| control.
|
| All that I'm trying to do is send a dynamic variable into that
treenodesrc
| string where that &variable is above.
|
| Hopefully I've explained this well enough. Let me know.
|
| Thanks.
|
|

Nov 19 '05 #2
Thanks Steven.

You definitely understand my problem. What is the
"GetNodeSrcFromDataBase()". Is that a command, a function I need to build...?
Also, it's not a big deal because I can translate fairly well, but I write in
VB.

I really appreciate the help. In my research and simply trying to develop
this, I've come across maybe a handful of articles even dealing with
treenodes, and even fewer retrieving records from a database.

Thank you,

Mark

"Steven Cheng[MSFT]" wrote:
Hi markaelkins,

Welcome to ASPNET newsgroup.
From your description, you're using the IE WEbcontrols's TreeView control
and use some dynamically retrieved xmldata from sqlserver to bind the nodes
in TreeView. Currently you're wondering how to dynamically assign the
TreeNodeSrc for certain TreeNodes in the TreeView, yes?

Based on my research, for the IE TreeView control, in the aspx inline
template, we can not use
<% ...%> render expression(also not allowed for assigning value to normal
webserver control's property) or
<%# ...%> databinding expression to assign dynamic value to TreeNode's
property. However, we can use code in codebehind or help function to
assign the property on the TreeNode instance and call its DataBind() method
to populate the dynamic children. For example:

===============
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{

tvMain.Nodes[0].TreeNodeSrc = GetNodeSrcFromDataBase();
tvMain.Nodes[0].Databind();

}
}

The TreeView has provide some function like TreeView.GetNodeFromIndex which
help use find node instance
through Node hierarchy.

Hope helps. Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| Thread-Topic: How to enter a variable in the treenodesrc of a treenode
| thread-index: AcW6AvT5x6w5gCYGTfWxLqsYXqsBLA==
| X-WBNR-Posting-Host: 67.79.167.182
| From: "=?Utf-8?B?bWFya2FlbGtpbnNAbmV3c2dyb3Vwcy5ub3NwYW0=?="
<ma*********@newsgroups.nospam>
| Subject: How to enter a variable in the treenodesrc of a treenode
| Date: Thu, 15 Sep 2005 07:37:11 -0700
| Lines: 34
| Message-ID: <2A**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:124805
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi. I am trying to enter a variable in the treenodesrc of a treenode. I
am
| basically trying to send an ID variable into sql to return different
records.
| I've searched everywhere and cannot find the answer. I'd appreciate and
help.
| Thanks.
|
| What I'm doing is creating a treeview with the structure as follows (this
is
| the expanded view):
|
| - Item Status
| - Item Status Details
| - Item Status Details
| - Item Status Details
|
| It's very basic. "Item Status" is the static <treenode text=. Now the
| treenodesrc is where I'm having my problem. I'm trying to send a dynamic
| variable into sql in order to return the associated records ("Item Status
| Details") using --
|
TreeNodeSrc="http://www.domain.com/sqlDataBaseName?sql=execute+StoredProcedu
| reName+@variable=&variable". The variable comes to the page through a
| querystring. Of course my code reflects my specifics. But I've set up
| XMLSQL, and when I hard code the variable into the string it works
perfectly.
| The query works, my stored procedure returns the proper XML, and my
TreeView
| looks exactly how I want it to look. But when I try to put a dynamic
variable
| in I get a Parser Error and says "The literal string - and then my
| treenodesrc string - was found. Literal strings are not allowed within
this
| control.
|
| All that I'm trying to do is send a dynamic variable into that
treenodesrc
| string where that &variable is above.
|
| Hopefully I've explained this well enough. Let me know.
|
| Thanks.
|
|

Nov 19 '05 #3
Hi Mark,

Thanks for your followup.
As for the "GetNodeSrcFromDataBase()", it's just a dummy function I used to
get a url string(for the TreeNode's TreeNodeSrc ....). So you can write
your own helper function to retrieve the TreeNode src url string from
database or other storage....

Anyway, currently we could only programmatically assign TreeNodeSrc
property through code behind code. In addition, since the IE webcontrols
are legacy components which are no longer supported, we'd also recommend
you consider migrating to the new Naviagation controls in the ASP.NET
2.0(whidbey).

Thanks & Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: How to enter a variable in the treenodesrc of a treenode
| thread-index: AcW6xxIb4YGbiE36Rh2knHiAN684ew==
| X-WBNR-Posting-Host: 24.227.52.74
| From: "=?Utf-8?B?bWFya2FlbGtpbnNAbmV3c2dyb3Vwcy5ub3NwYW0=?="
<ma*********@newsgroups.nospam>
| References: <2A**********************************@microsoft.co m>
<SZ*************@TK2MSFTNGXA01.phx.gbl>
| Subject: RE: How to enter a variable in the treenodesrc of a treenode
| Date: Fri, 16 Sep 2005 07:01:01 -0700
| Lines: 134
| Message-ID: <94**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet:125128
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Thanks Steven.
|
| You definitely understand my problem. What is the
| "GetNodeSrcFromDataBase()". Is that a command, a function I need to
build...?
| Also, it's not a big deal because I can translate fairly well, but I
write in
| VB.
|
| I really appreciate the help. In my research and simply trying to develop
| this, I've come across maybe a handful of articles even dealing with
| treenodes, and even fewer retrieving records from a database.
|
| Thank you,
|
| Mark
|
| "Steven Cheng[MSFT]" wrote:
|
| > Hi markaelkins,
| >
| > Welcome to ASPNET newsgroup.
| > From your description, you're using the IE WEbcontrols's TreeView
control
| > and use some dynamically retrieved xmldata from sqlserver to bind the
nodes
| > in TreeView. Currently you're wondering how to dynamically assign the
| > TreeNodeSrc for certain TreeNodes in the TreeView, yes?
| >
| > Based on my research, for the IE TreeView control, in the aspx inline
| > template, we can not use
| > <% ...%> render expression(also not allowed for assigning value to
normal
| > webserver control's property) or
| > <%# ...%> databinding expression to assign dynamic value to TreeNode's
| > property. However, we can use code in codebehind or help function to
| > assign the property on the TreeNode instance and call its DataBind()
method
| > to populate the dynamic children. For example:
| >
| > ===============
| > private void Page_Load(object sender, System.EventArgs e)
| > {
| > if(!IsPostBack)
| > {
| >
| > tvMain.Nodes[0].TreeNodeSrc = GetNodeSrcFromDataBase();
| > tvMain.Nodes[0].Databind();
| >
| > }
| > }
| >
| > The TreeView has provide some function like TreeView.GetNodeFromIndex
which
| > help use find node instance
| > through Node hierarchy.
| >
| > Hope helps. Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| > --------------------
| > | Thread-Topic: How to enter a variable in the treenodesrc of a treenode
| > | thread-index: AcW6AvT5x6w5gCYGTfWxLqsYXqsBLA==
| > | X-WBNR-Posting-Host: 67.79.167.182
| > | From: "=?Utf-8?B?bWFya2FlbGtpbnNAbmV3c2dyb3Vwcy5ub3NwYW0=?="
| > <ma*********@newsgroups.nospam>
| > | Subject: How to enter a variable in the treenodesrc of a treenode
| > | Date: Thu, 15 Sep 2005 07:37:11 -0700
| > | Lines: 34
| > | Message-ID: <2A**********************************@microsoft.co m>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > | charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA01.phx.gbl
| > microsoft.public.dotnet.framework.aspnet:124805
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > | Hi. I am trying to enter a variable in the treenodesrc of a treenode.
I
| > am
| > | basically trying to send an ID variable into sql to return different
| > records.
| > | I've searched everywhere and cannot find the answer. I'd appreciate
and
| > help.
| > | Thanks.
| > |
| > | What I'm doing is creating a treeview with the structure as follows
(this
| > is
| > | the expanded view):
| > |
| > | - Item Status
| > | - Item Status Details
| > | - Item Status Details
| > | - Item Status Details
| > |
| > | It's very basic. "Item Status" is the static <treenode text=. Now the
| > | treenodesrc is where I'm having my problem. I'm trying to send a
dynamic
| > | variable into sql in order to return the associated records ("Item
Status
| > | Details") using --
| > |
| >
TreeNodeSrc="http://www.domain.com/sqlDataBaseName?sql=execute+StoredProcedu
| > | reName+@variable=&variable". The variable comes to the page through a
| > | querystring. Of course my code reflects my specifics. But I've set up
| > | XMLSQL, and when I hard code the variable into the string it works
| > perfectly.
| > | The query works, my stored procedure returns the proper XML, and my
| > TreeView
| > | looks exactly how I want it to look. But when I try to put a dynamic
| > variable
| > | in I get a Parser Error and says "The literal string - and then my
| > | treenodesrc string - was found. Literal strings are not allowed
within
| > this
| > | control.
| > |
| > | All that I'm trying to do is send a dynamic variable into that
| > treenodesrc
| > | string where that &variable is above.
| > |
| > | Hopefully I've explained this well enough. Let me know.
| > |
| > | Thanks.
| > |
| > |
| >
| >
|

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by claireCSHARPuser | last post: by
reply views Thread by fred | last post: by
1 post views Thread by ghobley | last post: by
1 post views Thread by jmDesktop | last post: by
1 post views Thread by AAaron123 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.