Click to See Complete Forum and Search --> : DataBinder.Eval


aaryan
December 28th, 2006, 01:55 AM
hi all,
i just want an interpretation for the following code.

<EditItemTemplate>

Item:
<asp:Label id="Label1"
Text='<%# ((DataRowView)Container.DataItem)["Item"] %>'
runat="server"/>
Price:
<asp:TextBox id="Text2"
Text='<%# DataBinder.Eval(Container.DataItem, "Price") %>'
runat="server"/>

The second code means that we are binding to a datafield price of the datasource. Now what does the first code mean? under what circumstances or situations should we use each?

mcmcom
January 2nd, 2007, 02:37 PM
the first piece of code is that your binding a label to the "Item" field of the data set and your casting the Text property of the label to be a DataRowView. I believe this is used to select the entire row for viewing and im ASSUMING that Item is the primary key for that row. You use this when you want to click on an item in the DataGrid and have it be marked as editable.

hth,
mcm