1

私はGridViewでこのようなことをしたい:

<asp:CommandField ShowSelectButton="True" Visible='<%# return Eval("SC_TABLE") %>' />

しかし、それは機能せず、エラーが発生します:

データバインディング式は、DataBinding イベントを持つオブジェクトでのみサポートされます。System.Web.UI.WebControls.CommandField には DataBinding イベントがありません。

aspx ページから可視性を設定できる方法はありますか? PS: SC_TABLE はデータソースから存在するため、その部分に問題はありません。

4

2 に答える 2

3

代わりに TemplateField でこれを行うことができます...

<asp:TemplateField>
    <ItemTemplate>
        <asp:LinkButton runat="server" ID=SelectButton CommandName="SELECT" Visible='<%# Eval("SC_TABLE") %>' Text="Select" />
    </ItemTemplate>
</asp:TemplateField>
于 2009-07-16T15:01:35.740 に答える
1

この投稿の最後に答えが見つかりました:

基本的に、DataGrid で RowCreated イベントをキャプチャする必要があります。

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 がある場合に機能します。

于 2010-07-27T19:47:24.707 に答える