Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 88539
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:34:33+00:00 2026-05-10T22:34:33+00:00

Existing code is using an asp:repeater to build an HTML table. (emphasis on the

  • 0

Existing code is using an asp:repeater to build an HTML table. (emphasis on the existing design). This is some partial pseudo-code to generate the table:

<asp:repeater OnItemDataBound='ItemDataBound' ... >     <headertemplate>       <table>          <thead>             <tr>                <td>Date</td>                <td>Type</td>                <td>Action</td>             </tr>          </thread>    </headertemplate>     <itemtemplate>       <tr>          <td><%# GetTextForThis((MyItem)Container.DataItem) %></td>          <td><%# GetTextForThat((MyItem)Container.DataItem) %></td>          <td><%# GetTextForTheOther((MyItem)Container.DataItem) %></td>       </tr>    </itemtemplate>     <footertemplate>          </tbody>       </table>    </footertemplate>  </asp:repeater> 

But now it is needed that (some) items display differently, and it is needed that it is done using a COLSPAN=3, and the entire item will be one cell:

   <itemtemplate>       <tr>          <td colspan='3'>             <img src='<%# GetImageSrcForFoo((MyItem)Container.DataItem) %>             <a href='<%# GetHrefForFoo((MyItem)Container.DataItem) %>          </td>       </tr>    </itemtemplate> 

Given:

  • the page uses a repeater to build an HTML table
  • the design requires some table rows to span columns

How can i do this?

i was hoping for something like:

   <itemtemplate id='thisThatTheOtherItemTemplate'>       <tr>          <td><%# GetTextForThis((MyItem)Container.DataItem) %></td>          <td><%# GetTextForThat((MyItem)Container.DataItem) %></td>          <td><%# GetTextForTheOther((MyItem)Container.DataItem) %></td>       </tr>    </itemtemplate>      <itemtemplate id='fooItemTemplate'>       <tr>          <td colspan='3'>             <img src='<%# GetImageSrcForFoo((MyItem)Container.DataItem) %>             <a href='<%# GetHrefForFoo((MyItem)Container.DataItem) %>          </td>       </tr>    </itemtemplate> 

and somehow magically be able to have the OnDataBind event tell the repeater which template to use. Is this possble?

Answer

Although both answers are right and good, i’d rather use the first suggestion; which involves having display code in the aspx file, rather than building HTML manually in a code-behind. (i don’t want to ever have to build HTML in code again)

   <itemtemplate>       <asp:PlaceHolder ID='thing1' runat='server'>          <tr>             <td><%# GetTextForThis((MyItem)Container.DataItem) %></td>             <td><%# GetTextForThat((MyItem)Container.DataItem) %></td>             <td><%# GetTextForTheOther((MyItem)Container.DataItem) %></td>          </tr>       </asp:PlaceHolder>        <asp:PlaceHolder ID='thing2' visible='false' runat='server'>          <tr>             <td colspan='3'>                <img src='<%# GetImageSrcForFoo((MyItem)Container.DataItem) %>                <a href='<%# GetHrefForFoo((MyItem)Container.DataItem) %>             </td>          </tr>    </itemtemplate> 

and in the code-behind:

protected void myRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e) {    // if the data bound item is an item or alternating item (not the header etc)    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)    {       // get the associated object       Object item = .Item.DataItem;       if (item == null)          return;        Control thing1 = e.Item.FindControl('thing1');       Control thing2 = e.Item.FindControl('thing2');        if (item is MyClassThatICreated)       {          thing1.Visible = false;          thing2.Visible = true;       }       else       {          thing1.Visible = true;          thing2.Visible = false;       }       ... } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T22:34:33+00:00Added an answer on May 10, 2026 at 10:34 pm

    Place two ASP:Placeholder controls in your item template. In the codebehind, on the ItemDataBound event, determine which style you want to show, and hide one placeholder.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 179k
  • Answers 179k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer As long as its only your applet communicating with the… May 12, 2026 at 3:54 pm
  • Editorial Team
    Editorial Team added an answer Seems like you're probably observing some variety of a browser's… May 12, 2026 at 3:54 pm
  • Editorial Team
    Editorial Team added an answer Your problem is that when you're inside of an <mx:Component>… May 12, 2026 at 3:54 pm

Related Questions

I have an ASP.NET C# page where I am resizing the images in a
I'd like to use jQuery's dialog to replace some code I'm using right now
I hope this isn't a stupid question, but after searching around for quite a
My team is using FxCop to help clean up an existing ASP.NET application. We

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.