jialge
6/12/2008 3:56:00 AM
Hello Chunk
You may have noticed that Scott Gu's blog uses "Eval", a one-way
databinding keyword, to bind the 2-level property "Supplier.CompanyName".
It's not using the keyword "Bind". "Bind" supports two-way databinding,
i.e, both selecting and updating the data, however, it suffers from the
defects that it cannot bind mult-level properties. That's to say, if we
modify Scott's blog to use "Bind":
<asp:TemplateField HeaderText="Supplier"
SortExpression="Supplier.ComparyName">
<ItemTemplate>
<asp:Label runat="server" ID="lbl" Text='<%#
Bind("Supplier.CompanyName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
It will also throw the error "A call to Bind was not well formatted.
Please??" in the compilation time.
In order to work-around this problem and do "update" operations on the
Category column, Scott uses an additional dropdownlist "CategoryList" to
bind to the data source "CategoryDataSource". In this way, the "Text" shown
in UI is the readable category name, but the real value bound to the column
will still be the category ID, i.e. the one-level property.
All in all, "Eval" supports mult-level property, but does not support the
operation of "update", whereas, "Bind" supports "update", but it suffers
from one-level property binding. Therefore, Chunk, you may consider Scott's
workaround in his blog entry, or my two in the last reply. Is this
explanation helping you have a clearer picture about how "Bind" and "Eval"
work in databinding?
Thanks
Jialiang Ge (jialge@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
=================================================
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.
This posting is provided "AS IS" with no warranties, and confers no rights.
=================================================