Wednesday, February 29, 2012

Hide particular column into Grid on special condition

In Aspx :
----------

<telerik:GridBoundColumn DataField="LastName" UniqueName="LastName"
                                                                                                  HeaderText="Last Name" HeaderStyle-HorizontalAlign="Right">
                                                                                                    <ItemStyle HorizontalAlign="Right" />
                                                                                                </telerik:GridBoundColumn>



In Aspx.cs
-------------
protected void Page_Load(object sender, EventArgs e)
        {
HideColumn("LastName "); //-- Column Name
}


private void HideColumn(string uniqueName)
        {
            GridColumn gridCol = dgSiteList.Columns.FindByUniqueNameSafe(uniqueName);
            if (gridCol != null)
                gridCol.Visible = false;
        }

No comments:

Post a Comment