This is a migrated thread and some comments may be shown as answers.

[Solved] ASP.Net DataBinding & Templates

0 Answers 83 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Dieter
Top achievements
Rank 1
Dieter asked on 16 Jun 2009, 02:14 PM

Dear Forum,

I found this german blog   http://www.encodo.info/en/blogs.php?entry_id=156

Now I like to know with way of the next to is faster. Hope you can help me to understand.

 

Thank U for help

 

Best from

Dieter 

 

1st

<asp:DataList ID=“_myList” runat=“Server”>
   <ItemTemplate>
     <asp:Label … Text=‘<%# GetFormattedDate(Eval(“Birthday”)) %>’></asp:Label>
   </ItemTemplate>
</asp:DataList>

 

 

 

CodeBehind:

public partial class MyPage : System.Web.UI.Page
{

  protected String GetFormattedDate(object date)
  {
    if (date is DateTime)
    {
      return ((DateTime)date).ToShortDateString();
    }

    return String.Empty;
  }

} 

 

2nd

<asp:DataList ID=“_myList” runat=“Server”>
   <ItemTemplate>
     <birth:day id="birth001" runat="server" Birthday=‘Eval(“Birthday”) %>’/>
   </ItemTemplate>
</asp:DataList>

 

ascx

 

<asp:Label  ID="L_Birthday" runat="server" ></asp:Label>

 


public partial class UserControls_birthday : System.Web.UI.UserControl

{

public DateTime bday{

 

set

{

L_Birthday.text = value.ToShortDateString();

}

}

 

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
Dieter
Top achievements
Rank 1
Share this question
or