Asp.Net: Databinding a array of strings

by Pieter Brinkman 30. January 2009 03:47

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

Code example

Codebehind:

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


And in the .aspx:

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

Tags: , , , ,

ASP.Net | Controls

ListView: OnItemDataBound

by Pieter Brinkman 23. July 2008 22:57

Get dataItem onItemDataBound (don't forget to replace the bold parts with your objectname):

protected void MainPostListView_ItemDataBound(object sender, ListViewItemEventArgs e)

{

YourObject item = (YourObject)((ListViewDataItem)e.Item).DataItem;

}

 

Findcontrol within the itemtemplate:

HyperLink hplTitle = (HyperLink)e.Item.FindControl("hyperLink");

 

 

Tags: , , , ,

ASP.Net | Controls

Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen

About Me

My name is Pieter Brinkman I am a .NET Software Engineer for Achmea IT in De Meern, The Netherlands. My interests are mainly web applications created with ASP.NET, MSSQL and Silverlight.

Calendar

<<  September 2010  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
27282930123
45678910

View posts in large calendar

RecentComments

Comment RSS

Most comments

club penguin cheats club penguin cheats
4 comments
us United States
Web Design Company Web Design Company
2 comments
Web design Web design
2 comments
gb United Kingdom