Webmaster Forums Banner Professional Hosting from Just Host
Welcome Guest Search | Active Topics | Members | Log In | Register

Asp:label or Data binding C# Options
sachin
Posted: Thursday, May 22, 2008 6:17:55 AM
Rank: Advanced Member
Groups: Member

Joined: 3/3/2008
Posts: 79
Points: 237
Location: India
i have a newbie question!

For data that is not part of a list, which is preferred, to use asp:Label and set the values for the labels in the Page_Load or to create a property on the page for the object with the data and bind to that object?

Code:
Ex1:
(in .aspx)
<asp:Label ID="myField" runat="server" />

(in Page_Load)
myField.Text = myObject.someValue;


or

Code:
Ex2:
(in .aspx)
<%# MyObject.someValue %>

(in .aspx.cs)
public Object MyObject { get; set; }

(in Page_Load)
MyObject = someObject;
Page.DataBind();


Sponsor
Posted: Thursday, May 22, 2008 6:17:55 AM
rasheed
Posted: Thursday, May 22, 2008 6:21:16 AM
Rank: Advanced Member
Groups: Member

Joined: 1/31/2008
Posts: 42
Points: 126
Location: UK
hi Sachin

using some label or an html control and passing value to it is most common practices

thanks
Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

ASPNET Theme created by Boskone (Dan Ferguson)
Powered by HaqTech.Com
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.387 seconds.