Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Server control derived from Repeater?

Reply
Thread Tools

Server control derived from Repeater?

 
 
Dobedani
Guest
Posts: n/a
 
      11-26-2003
Dear All,

I would like to use a Repeater to show data - mostly large volumes
from a database - in a comma delimited format. VS.NET documentation
mentions this as one of the uses of the Repeater! Actually, the idea
is that users can save the output of a request as CSV file on their
desktop. For that reason, I stripped my aspx of all html and left only
the first line:
<%@ Page language="c#" Codebehind="csv.aspx.cs" etc. %>

I hope to be able to add the repeater on the fly, like in the
following:
Repeater rptData = new Repeater();
this.Controls.Add(rptData);

However, it appears impossible to edit the templates in the code. I
tried assigning strings to the HeaderTemplate and ItemTemplate, but I
got:
Cannot convert type 'string' to 'System.Web.UI.ITemplate' even when I
tried to cast my strings.

I am now thinking that to create a server control derived from
Repeater is the way forward. Am I right? How to go about it? And what
should the ItemTemplate look like? I hope to avoid databinding with
DataBinder.Eval because that will make the page terribly slow.
Moreover, the number of columns is variable (max. 13). I hope somebody
can help me. TIA

Kind regards,
Dobedani
Wageningen
The Netherlands
 
Reply With Quote
 
 
 
 
Tommy
Guest
Posts: n/a
 
      11-27-2003
I have never tried adding columns to a repeater control dynamically,
but I have done this with a datagrid control, and I think the
technique whould be very similar.

1. You need to create a class that implments ITemplate
2. In this class, implement InstantiateIn.
InstantiateIn allows you to
a. Modify the template to contain any control you like
b. Attach a handle the databinding event.
3. Create a method that will handle the databinding event, such as
HandlingDataBinding
4. In the HandlingDataBinding method, you can add the data from your
data source to your controls.
5. For each column you need in the repeater control, add an instance
of the
class you've created above.

Tommy,

http://www.velocityreviews.com/forums/(E-Mail Removed) (Dobedani) wrote in message news:<(E-Mail Removed). com>...
> Dear All,
>
> I would like to use a Repeater to show data - mostly large volumes
> from a database - in a comma delimited format. VS.NET documentation
> mentions this as one of the uses of the Repeater! Actually, the idea
> is that users can save the output of a request as CSV file on their
> desktop. For that reason, I stripped my aspx of all html and left only
> the first line:
> <%@ Page language="c#" Codebehind="csv.aspx.cs" etc. %>
>
> I hope to be able to add the repeater on the fly, like in the
> following:
> Repeater rptData = new Repeater();
> this.Controls.Add(rptData);
>
> However, it appears impossible to edit the templates in the code. I
> tried assigning strings to the HeaderTemplate and ItemTemplate, but I
> got:
> Cannot convert type 'string' to 'System.Web.UI.ITemplate' even when I
> tried to cast my strings.
>
> I am now thinking that to create a server control derived from
> Repeater is the way forward. Am I right? How to go about it? And what
> should the ItemTemplate look like? I hope to avoid databinding with
> DataBinder.Eval because that will make the page terribly slow.
> Moreover, the number of columns is variable (max. 13). I hope somebody
> can help me. TIA
>
> Kind regards,
> Dobedani
> Wageningen
> The Netherlands

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Derived Structure in Derived Class?? David C++ 3 01-29-2008 07:38 AM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 01:44 PM
Derived::Derived(const Base&) developereo@hotmail.com C++ 4 05-23-2007 09:32 AM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 12:07 AM
rendering derived control from composite control William French ASP .Net Building Controls 1 12-03-2003 01:20 AM



Advertisments