因此,在ASP中进行双向数据绑定,我们这样做...
<asp:textbox id="txtField" runat="server"
text='<%# Bind("SomeField") %>'>
</asp:textbox>
SomeField位于DetailsView的DataSource中,作为文本框的容器。
或者我可以在代码后台执行此操作(使用文本框的OnDataBinding事件):
protected void SomeField_OnDataBinding(object sender, EventArgs e)
{
((TextBox)sender).Text = Eval("SomeField").ToString();
}
然而,EVAL是只读的...我怎么能在代码后端指定绑定(双向)?