By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,925 Members | 732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,925 IT Pros & Developers. It's quick & easy.

how to make a user control that uses templates?

P: n/a
Are there any samples of how to create a user control that uses
templates, like the <ItemTemplate> and <HeaderTemplate> of the
Repeater control?

I tried searching for user control samples on the Web but couldn't
find any that used templates.

What I'm (still) trying to do is display a hierarchical listing of
data rows from a table that have a parent-child relationship, e.g.
rows representing user posts on a message board, with some rows having
a parent_posting_ID field set to the ID of the post that the message
is replying to. Like:

learning ASP
|
+- Re: learning ASP
|
+- Re: learning ASP
.......|
.......+- Re: learning ASP

debugging ASP code
|
+- Re: debugging ASP code

(The Microsoft.Web.UI.WebControls.TreeView control seems like overkill
since it uses client-side scripting to make nodes expandable and
collapsable, which I don't need, and may not work well in other
browsers or browsers with scripting turned off.)

So I was thinking if I could create a user control with templates, I
could create one with a <NodeTemplate> that would display the data for
the node (e.g. "Re: learning ASP" in the example above), and a
<NodePrefix> template that would precede any node except a top-level
node (the plus sign in my little ASCII art above), and a
<IndentationPrefix> template that would repeat itself a certain number
of times to indent the node over the right amount, to indicate its
depth in the hierarchy.

Of course if anyone knows an easier, built-in way, that would be ideal
:)

-Bennett
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Try searching google for "Templated Control"...

Scott Mitchell has a couple good articles:

http://msdn.microsoft.com/asp.net/de...SrvrCntrls.asp

http://msdn.microsoft.com/library/de...edcontrols.asp

The topic is slightly advanced...
Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Bennett Haselton" <be*****@peacefire.org> wrote in message
news:e6*************************@posting.google.co m...
Are there any samples of how to create a user control that uses
templates, like the <ItemTemplate> and <HeaderTemplate> of the
Repeater control?

I tried searching for user control samples on the Web but couldn't
find any that used templates.

What I'm (still) trying to do is display a hierarchical listing of
data rows from a table that have a parent-child relationship, e.g.
rows representing user posts on a message board, with some rows having
a parent_posting_ID field set to the ID of the post that the message
is replying to. Like:

learning ASP
|
+- Re: learning ASP
|
+- Re: learning ASP
......|
......+- Re: learning ASP

debugging ASP code
|
+- Re: debugging ASP code

(The Microsoft.Web.UI.WebControls.TreeView control seems like overkill
since it uses client-side scripting to make nodes expandable and
collapsable, which I don't need, and may not work well in other
browsers or browsers with scripting turned off.)

So I was thinking if I could create a user control with templates, I
could create one with a <NodeTemplate> that would display the data for
the node (e.g. "Re: learning ASP" in the example above), and a
<NodePrefix> template that would precede any node except a top-level
node (the plus sign in my little ASCII art above), and a
<IndentationPrefix> template that would repeat itself a certain number
of times to indent the node over the right amount, to indicate its
depth in the hierarchy.

Of course if anyone knows an easier, built-in way, that would be ideal
:)

-Bennett

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.