by Pieter Brinkman
24. September 2009 07:13
With the following code you can format a DateTime within a Databind.
[code:c#]
<%# DateTime.Parse(Eval("DateModified").ToString()).ToString("MM-dd-yyyy")%>
[/code]
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>
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");