访问服务器端的按钮

时间:2012-12-10 06:50:50

标签: c# asp.net vb.net c#-4.0 devexpress

我的代码:

<dx:ASPxTreeList ID="treeList" runat = "server">
    <Columns>
      <dx:TreeListDataColumn Name="Edit" FieldName="EditColumn">
        <DataCellTemplate>
          <dx:ASPxButton ID="btnSample" runat="server" Text="SampleText">
          </dx:ASPxButton>
        </DataCellTemplate>
       </dx:TreeListDataColumn>
    </Columns>
    </dx:ASPxTreeList>

我的目标是在btnSample处将按钮Page_Load显示为false。因此,我需要访问服务器端btnSample事件的Page_Load ID。我不知道如何访问服务器端ID内按钮的TrreListDataColumn

1 个答案:

答案 0 :(得分:2)

处理ASPxTreeList.HtmlDataCellPrepared事件:

protected void TreeList_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e)
{
    int empId = (int) e.GetValue("EmpID");
    if ("EditColumn".Equals(e.Column.FieldName) && empId == 1)
    {
        ASPxButton button = (ASPxButton) treeList.FindDataCellTemplateControl(e.NodeKey, e.Column, "btnSample");
        if (button != null)
            button.Visible = false;
    }
}