Pieter Brinkman

Asp.Net: Databinding a array of strings

1 min readpieterASP.NetControls

You can use a string array as datasource and view the string values by using the Container.DataItem property.

Code example

Codebehind:

[code:c#]

string[] testData = {"1","two","3","4"};
rptDemo.DataSource = testData;
rptDemo.DataBind();

[/code]

And in the .aspx:

<asp:Repeater runat="server" ID="rptDemo">  
    <ItemTemplate>  
        <%# Container.DataItem %>  
    </ItemTemplate>  
</asp:Repeater>