CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 10/5/2005 1:04:49 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 1 Views: 515 Favorited: 0 Favorite
2 Items, 1 Pages 1 |< << Go >> >|
Miketrix
Asp.Net User
Create a Custom Repeater Control (with conditional Templates)10/5/2005 1:04:49 PM

0

Hello all,

I was wondering how I could develop a customized repeater control (as the asp.net one) but with the following feature :

instead of specifying <ItemTemplate> and <AlternateItemTemplate> and header and footer template, I would like to have conditional templates, defined (a first idea, but maybe there are some better ways to do it ... ) like this :

<asp:repeater ... >
   <template name="Car">
      <tr><td colspan="2"><%# Databinder.Eval( ... The brand of the car ... ) %> <td><tr>
   </template>

    <template name="Animal">
      <tr>
         <td><%# Databinder.Eval( ... The name of the animal... ) %> <td>
         <td><%# Databinder.Eval( ... The age of the animal... ) %> <td>
      <tr>
   </template>
   
    <template name="Person">
      <tr>
         <td><b><%# Databinder.Eval( ... The name of the person... ) %><b> <td>
         <td><%# Databinder.Eval( ... The age of the person... ) %> <td>
      <tr>
   </template>

</asp:repeater>

Well, this is a stupid example but as you can see, this way of "templating" a repeater let us specify different contents / styles to render according to some conditional statements... I mean, we would have to be able to define (maybe in codebehind, or any other solution i didn't invented yet ) to tell :

use the Template "Car" when DataBoundItem.Category = 1
use the Template "Animal" when DataBoundItem.Category > 1 AND DataBoundItem.IsAnimal = true
use the Template "Car" when DataBoundItem.Category = 1 AND DataBoundItem.IsAnimal = false
// and even define a "default Template" when none of the upper conditions where associated to a template ...

Well, that's a first idea but for now I haven't found any way to do that in an ASP.Net spirit (actually, I think about that needed feature because of migration of an ASP 3.0 projet, where we were always using <% for ...  %> statements directly in html code... where you can build you html in a loop in a simplier way than we can do it now with asp.net ...

Please let me know your opinion about that problem and maybe some advice on how to develop the idea of custom templates (haven't found any documentation yet .... ) or maybe a way to do it with existing components ... ( but with aspx support, not by doing it entirely in code behind ... I hate having to define html tags in codebehind as string variables ... that isn't the way I like to develop in ASP.Net ...)

Thank's all for your attention !

Mike.

-- Miketrix
Better to know much about nothing or to a little about everything ?
datagridgirl
Asp.Net User
Re: Create a Custom Repeater Control (with conditional Templates)10/5/2005 3:08:10 PM

0

Hi Mike,
If you want do this with the out-of-the-box Repeater, you can do it like so:

<asp:repeater ... >
   <ItemTemplate>
      <tr runat="server" id="car" Visible=<%#(Container.DataItem("Category") = 1)%>>
         <td colspan="2"><%# Databinder.Eval( ... The brand of the car ... ) %> <td>
       <tr>
       <tr ruant="server" id="animal" Visible=<%#(Container.DataItem("Category") = 1 AND Container.DataItem("IsAnimal") = 1)%>>
         <td><%# Databinder.Eval( ... The name of the animal... ) %> <td>
         <td><%# Databinder.Eval( ... The age of the animal... ) %> <td>
      <tr>
  </ItemTemplate>
</asp:repeater>

You can still go down the path of creating your own Server Control with named templates, but this may give you some ideas.

Marcie

http://www.datagridgirl.com
NEW! http://www.gridviewgirl.com
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
ASP.NET: Your Visual Blueprint for Creating Web Applications on the .Net Framework Authors: Danny Ryan, Thomas Ryan, Tommy Ryan, Pages: 320, Published: 2001
Building an ASP.NET intranet Authors: Kourosh Ardestani, Brian Boyce, Jonathon Walsh, et al., Andy Elmhorst, Matt Gibbs, Pages: 480, Published: 2003
Visual Basic .NET power coding Authors: Paul Kimmel, Pages: 708, Published: 2004
Microsoft Office SharePoint Designer 2007 Authors: Vikram Kartik, Pages: 600, Published: 2009
Sams Teach Yourself ADO.NET in 24 Hours Authors: Jason Lefebvre, Paul Bertucci, Pages: 389, Published: 2002

Web:
Create a Custom Repeater Control (with conditional Templates ... Create a Custom Repeater Control (with conditional Templates) ... header and footer template, I would like to have conditional templates, ...
Pravins Blog: Empty data template for repeater control means if count is 0 den make the repeater as visible="false" this is ok for the condition ... Labels: asp.net, Custom Repeater Control, Empty Data Template, ...
ASP.NET Repeater control or custom implementation? - Stack Overflow Of course, that it's possible to achieve the same with repeater control, ... properties and events inside any databound control by using the Ondatabound, Onitem create, ... NET Repeater Template, Conditional Code for every Nth element ...
Using the ASP.NET Repeater Control [ASP & .NET Tutorials] NET's Repeater Control to build the menu on his site. ... The Repeater control allows you to create templates to define the layout of its content. .... Custom Twitter Backgrounds · Choose from dozens, created just for you. ... ValidationExpression · conditional rendering · Clearing Data Cache (Non- Programatically) ...
Form and Field Controls You can create custom field controls that inherit the basic field functionality ... Conditional rendering of forms and fields through control templates or code ... ListFieldIterator repeater control within a form follows the field order ...

Create a Custom Repeater Control (with conditional Templates) - ng ... Create a Custom Repeater Control (with conditional Templates), > ROOT > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum, ...
asp:repeater sitemap - ng.asp-net-forum ... Create a Custom Repeater Control (with conditional Templates) - ng ... Well, this is a stupid example but as you can see, ... You can still go down the path ...
Extending DataGrid with ITemplate - ng.asp-net-forum.windows ... Create a Custom Repeater Control (with conditional Templates) - ng ... Dynamic Templates for the Repeater, DataList and DataGrid Controls ost of the time, ...
Using RenderControl to Capture Output from a User Control - ng.asp ... composite control with validators and inamingcontainer · create a custom repeater control (with conditional templates) · customizing a dropdownlist ...
validator Unable to find Control ID - ng.asp-net-forum.windows ... create a custom repeater control (with conditional templates) · how do i override a control property · cannot use cssclass when inheriting label ...






how to create a custom dropdownlist webcontrol in c#

anti-virus for x64 wss 3.0

controldesigner

creating customer contorls properties and events

can't set calendar properties

gridview

raising post back for a custom server control

hosting asp.net 2.0 applications

composite server controls and performance

override xml property

any one hosting with ultima now.....?

hosting need of asp 2.0 and sql 2005

hosting using .aspx files

asp.net server control written in vb.net (datagrid)

collection property's items in inner tags for datagrid

discountasp.net

dynamic user control postback not firing

passing values from a user control

general web hosting questions

on-line documentation (.chm)

viewstate in composite controls

help with manually rendering required field validator

more intelligent question

load control from given string type

how to use templatebuilder

temporarily disable loadviewstate

how to build a control that runs on the client side?

controldesigner "missing assembly reference"

binding properties to application configuration (ie. web.config)

any free asp hosts?

   
  Privacy | Contact Us
All Times Are GMT