Hi all,
First and foremost I am a person who hates to add C# code to aspx file and prefer using only codebehind. I know there are certain scenarios where it is impossible to evade but thats another matter.
I have a repeater with a DataView as a DataSource. In the repeater I display product details from the columns in the dataview. Now there are two ways I tend to use to display data like say the product name:
in the aspx file just add:
or
have a label (lblProductName ) in the aspx file and in the cs file on Item_Databound I use FindControl as follows:
I personally prefer the second though there is more work involved. It is also good for me since usually I format the data before I display it.
Now my question is: Which method is better keeping in mind speed/overhead?? Or are they identical?
Thanks
First and foremost I am a person who hates to add C# code to aspx file and prefer using only codebehind. I know there are certain scenarios where it is impossible to evade but thats another matter.
I have a repeater with a DataView as a DataSource. In the repeater I display product details from the columns in the dataview. Now there are two ways I tend to use to display data like say the product name:
in the aspx file just add:
Code:
<%#Eval("product_name")%>
have a label (lblProductName ) in the aspx file and in the cs file on Item_Databound I use FindControl as follows:
Code:
Label lblProductName = (Label) e.Item.FindControl("lblProductName"); lblProductName.Text = Convert.ToString(((DataRowView)e.Item.DataItem)["product_name"]);
Now my question is: Which method is better keeping in mind speed/overhead?? Or are they identical?
Thanks
Comment