2009-07-16 2 views
1

aspx 페이지에서 :세트있는 CommandField를 선택하여 공개 나는의 GridView와 같은 것을하고 싶지

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

하지만 그건 오류로 올라오고, 작동하지 않습니다

Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.CommandField does not have a DataBinding event.

어쨌든 거기 aspx 페이지에서 가시성을 설정할 수 있습니까? PS : SC_TABLE이 데이터 소스에서 존재하므로 그 부분의 오류는 없습니다. 당신은 대신 TemplateField 함께 할 수

답변

3

...

<asp:TemplateField> 
    <ItemTemplate> 
     <asp:LinkButton runat="server" ID=SelectButton CommandName="SELECT" Visible='<%# Eval("SC_TABLE") %>' Text="Select" /> 
    </ItemTemplate> 
</asp:TemplateField> 
+0

+1 : CommandField로 해보고 싶습니다. 나는 이미이 방법을 알고 있었지만 여전히 도움이되었습니다. 오, CommandField에서는 불가능한 것처럼 보입니다. : ( – waqasahmed

+0

다른 사람이 더 나은 답변을 제공 할 수있는 경우를 제외하고, 나는이 답변을 며칠 후에 승인으로 표시 할 것입니다. – waqasahmed

1

나는 this post의 말에 대답을 발견

는 기본적으로, 당신은 데이터 그리드에 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가 있으면 작동합니다.

관련 문제