2007年9月4日 星期二

.NET data binding expression

We often use data binding expressions in the following way:

<asp:TextBox ID="tbx_Master" runat="server" Text='<%# Eval("org_master")
%>'></asp:TextBox>

But sometimes it requires explicit type conversion for the expression to work correctly. Otherwise the system will try to perform an implicit conversion for which an InvalicCastException might be thrown if not done right. For example:

<asp:RadioButton ID="rb_Master" runat="server" Checked='<%#
Convert.ToBoolean(Eval("org_master")) %>' GroupName="Master" />

沒有留言: