Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Problem using dynamic Datalist templates - Newbie

Reply
Thread Tools

Problem using dynamic Datalist templates - Newbie

 
 
dresde from NYC
Guest
Posts: n/a
 
      12-09-2004
Hi there!

Hopefully somebody can help as I am getting desperate.

I am using C# to develope a web user control containing a DataList and I
want my DataList to look different depending on some control properties.

To achieve that I use "Page.LoadTemplate (myTemplateName)". I do this on my
OnInit event to make sure my controls are created before LoadViewState etc
and avoid problems when posting back.

My problem is that I need to pass the name of the template to load during
OnInit. Therefore I cannot use the control properties yet. Any idea how to do
this? I have read all the articles about dynamic controls etc but I can't
find anything

Any help/hint/suggestion/comment/question will be greatly appreciated

Thanks in advance!

Diana Carrasco, NYC
 
Reply With Quote
 
 
 
 
dresde from NYC
Guest
Posts: n/a
 
      12-10-2004
Hi!

Just wanted to let you know I have solved the problem.

I now create my control dynamically using LoadControl and AddControl. Just
before calling AddControl I set the value of one of the control properties.
It works!

It would look like this:

================================================== =====

protected System.Web.UI.Control ctl1;

ctl1 = LoadControl("myTestControl.ascx");

((myTestControl)ctl1).myTemplate = this.myTemplate;

myPlaceHolder.Controls.Add(ctl1);

================================================== =====

Cheers,

Diana.

 
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
how to Specializations of function Templates or Overloading Function templates with Templates ? recover C++ 2 07-25-2006 02:55 AM
Using templates..problem with DataList =?Utf-8?B?UmFwaA==?= ASP .Net 0 11-01-2004 09:04 PM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
Templates templates templates JKop C++ 3 07-21-2004 11:44 AM
using templates in templates John Harrison C++ 8 07-31-2003 12:00 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57