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

  • SEARCH
  • Home
  • 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 7781713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:19:00+00:00 2026-06-01T19:19:00+00:00

I use a Repeater to read from different tables, since tables has different columns,

  • 0

I use a Repeater to read from different tables, since tables has different columns, I’ll have to use a dynamic template.

 <asp:Repeater ID="tableData" runat="server" DataSourceID="SqlDataSource2">
           <ItemTemplate>
                     <asp:PlaceHolder ID="tableBody" runat="server">
                            </asp:PlaceHolder>
           </ItemTemplate>
 </asp:Repeater>

But VS 2010 doesn’t seem to recognize the placeholder nested in the repeater.

So I tried to let the placeholder generate the repeater, but how can I change the inner code by hand? There’s no “innerHtml” option.

UPDATE

I’m note sure If placeholder is approriate , but what I want is to generate stuff inside <ItemTemplate> dynamically , which is things like <%# DataBinder.Eval(Container.DataItem, "username") %>

Because I’m reading different table column from different tables , this need to be selected base on the table user wanted.

So I need to modify the ASPX code before it’s being processed , is there any better way to do this ?

  • 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. Editorial Team
    Editorial Team
    2026-06-01T19:19:02+00:00Added an answer on June 1, 2026 at 7:19 pm

    Visual Studio won’t pick up a control that is nested in a Repeater. For this, you will need to use FindControl to access the control in the Repeater.

    Here are two examples you can use to access a control within a Repeater.

    1) Looping through Repeater items

    foreach (RepeaterItem item in tableData.Items)
    {
        if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
        {
            var ph = (PlaceHolder)item.FindControl("tableBody");
    
            //Do something with your placeholder
            ph.Visible = true;
        }
    }
    

    2) Use the ItemDataBound event on the Repeater

    void tableData_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            var ph = (PlaceHolder) e.Item.FindControl("tableBody");
    
            //Do something with your placeholder
            ph.Visible = true;
        }
    }
    

    If you plan on using the ItemDataBound event, you will need to add the following attribute to your Repeater:

    OnItemDataBound="tableData_ItemDataBound"
    

    Could you clarify what you exactly want to do with your Placeholder? There is no “innerHTML” property for a Placeholder. I think you are getting mistaken with JavaScript. I presume you want to populate your a control inside your repeater with some Html. You could use a Literal instead.

    Edit

    Using a Literal to populate the Repeater dynamically based on data from database.

    void tableData_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            //Get column from datasource
            DataRowView drv = (DataRowView)e.Item.DataItem;
    
            var lit = (Literal) e.Item.FindControl("MyLiteral");
    
            //Populate Literal with data
            StringBuilder htmlMarkup = new StringBuilder();
    
            htmlMarkup.AppendFormat("{0}<br />", drv["username"].ToString());
            htmlMarkup.AppendFormat("{0}<br />", drv["Name"].ToString());
            htmlMarkup.AppendFormat("{0}<br />", drv["lastname"].ToString());
    
            lit.Text = htmlMarkup.ToString();
        }
    }
    

    As you can see I am retrieving the data and outputting what I want in the format I want.

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

Sidebar

Related Questions

I read that one cannot use ASP.NET MVC with Server Control which have ViewState
I have a streaming input which has repeated values. I can use any data
I have a grid with repeated columns with same style but different names the
Using ASP.NET 4.0 WebForms. I have a repeater with checkboxes in it. The repeater
I have read the documentation, examples and tutorials of how to use the Google
i am a newbie programmer in ASP.NET. So My database have two tables: UserTypes
I use asp.net 4 and C#. I have some nested Master Pages; I display
A table row is generated using an asp:Repeater: <asp:repeater ID=announcementsRepeater OnItemDataBound=announcementsRepeater_ItemDataBound runat=Server> <itemtemplate> <tr
Relevant code from DetailsBERS.ascx file: <%@ Register Src=BERS.ascx TagName=BERS TagPrefix=ucBERS %> <asp:Repeater ID=repeatBERS runat=server><ItemTemplate>
I have to write a program that read from a file that contains the

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.