When you bind any database element to your aspx/design page, you use this property. There's something called as Databinder.Eval for which someone gets confused with Container.DataItem.
Container.DataItem gets the current row of that collection. It is a runtime alias for the DataItem for this specific collection item.
This link would be helpful for you to have a glance on it.
I have read this already. But I am not really sure what it means by DataItem. Is DataItem a specific piece of data retrieved from a database?
DataBinder.Eval(Container.DataItem, "Price"). Does it mean that the computer looks through the database and find the specific row and get the piece of data from the Price field or Price column within that row?
So what about this
Container.DataItem("EmployeeName")and
DataBinder.Eval(Container.DataItem, "EmployeeName")
This is the binding syntax code. The DataItem means getting data from the datasource of the binding control such as GridView or ListView. Then give a name for the dataitem to specify which field you want to get here from the whole datasource.
jinkazuya
0 Points
2 Posts
What is Container.DataItem
Apr 16, 2012 12:35 AM|LINK
I have read somebody posted this on other forum...But the answer is kind of vague.
So I am just wondering if somebody could really tell me or explain what it is?
I have also done some google search and cannot find a better answer.
subhash.shel...
Contributor
2137 Points
487 Posts
Re: What is Container.DataItem
Apr 16, 2012 01:47 AM|LINK
Hi,
below link might be help you better....
http://www.jstawski.com/archive/2007/11/13/container-dataitem-what-exactly-is-this.aspx
Thanks
Subhash
Please, Mark as Answer if this reply helped you.
Srikanth Kas...
Contributor
4289 Points
883 Posts
Re: What is Container.DataItem
Apr 16, 2012 06:19 AM|LINK
When you bind any database element to your aspx/design page, you use this property. There's something called as Databinder.Eval for which someone gets confused with Container.DataItem.
Container.DataItem gets the current row of that collection. It is a runtime alias for the DataItem for this specific collection item.
This link would be helpful for you to have a glance on it.
http://weblogs.asp.net/rajbk/archive/2004/07/20/what-s-the-deal-with-databinder-eval-and-container-dataitem.aspx
Srikanth Kasturi
Please "Mark As Answer" if my post serves purpose.
jinkazuya
0 Points
2 Posts
Re: What is Container.DataItem
Apr 16, 2012 10:41 PM|LINK
I have read this already. But I am not really sure what it means by DataItem. Is DataItem a specific piece of data retrieved from a database?
DataBinder.Eval(Container.DataItem, "Price"). Does it mean that the computer looks through the database and find the specific row and get the piece of data from the Price field or Price column within that row?
So what about this Container.DataItem("EmployeeName")and DataBinder.Eval(Container.DataItem, "EmployeeName")
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: What is Container.DataItem
Apr 18, 2012 08:16 AM|LINK
Hi,
This is the binding syntax code. The DataItem means getting data from the datasource of the binding control such as GridView or ListView. Then give a name for the dataitem to specify which field you want to get here from the whole datasource.
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework