我想用GridView来做这样的事情:
<asp:CommandField ShowSelectButton="True" Visible='<%# return Eval("SC_TABLE") %>' />但这是行不通的,出现了错误:
只有在具有Databinding事件的对象上才支持数据库化表达式。System.Web.UI.WebControls.CommandField没有DataBinding事件。
无论如何,我可以从aspx页面设置可见性吗?PS: SC_TABLE是从数据源中存在的,所以这部分没有什么问题。
发布于 2009-07-16 15:01:35
你可以用TemplateField代替.
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton runat="server" ID=SelectButton CommandName="SELECT" Visible='<%# Eval("SC_TABLE") %>' Text="Select" />
</ItemTemplate>
</asp:TemplateField>发布于 2010-07-27 19:47:24
我在这个职位的结尾找到了答案
基本上,您需要在RowCreated上捕获DataGrid事件
OnRowCreated="GridView1_RowCreated“
然后,在aspx.cs页面上使用以下代码隐藏控件:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowIndex == 1)
{
e.Row.Cells[0].Controls.Clear();
}
}如果在第一列中有一个CommandField,它就能工作。
https://stackoverflow.com/questions/1138176
复制相似问题