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 ?
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
2) Use the
ItemDataBoundevent on the RepeaterIf you plan on using the
ItemDataBoundevent, you will need to add the following attribute to your Repeater: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.
As you can see I am retrieving the data and outputting what I want in the format I want.