Difference between a custom template and a user control?

  • Thread starter Thread starter Barry
  • Start date Start date
B

Barry

I have a DataList in which I need to dynamically load a
SelectedItemTemplate. However, I ended up turning the template into a
User Control because I needed code behind. The reason I did this was
because I have another DataList inside the template/control that has to
be bound to a function call and I couldn't figure out how to do this in
a template.

I'm still using MyDataList.SelectedItemTemplate =
LoadTemplate("./Path/To/MyControl.ascx"), which sort-of works. The
problem I'm having is that I want an item in my template/control to
reload the top Datalist with a different template/control when a certain
item is clicked in the sub-DataList and it doesn't seem to work.

Is there a difference between the two technologies? Did I not need to
use a User Control to get what I needed? I feel like I've read a ton on
these things and I get a little more confused every day. Can anyone
point me in the right direction?

TIA,
Barry
 
Hi,

you can use public functions from the code behind to set Template
attribute values :

<ITEMTEMPLATE>
<P width="<%#New
Unit(Container.Width)%>"><%#GetSystemName(Container.DataItem)%></P>
</ITEMTEMPLATE>

Hope it helps you.



Natty Gur, CTO
Dao2Com Ltd.
34th Elkalay st. Raanana
Israel , 43000
Phone Numbers:
Office: +972-(0)9-7740261
Fax: +972-(0)9-7740261
Mobile: +972-(0)58-888377
 
Back
Top