Hide Gridview column at Runtime in ASP .net.

Hide Gridview column at Runtime in ASP .net.

Hello Everyone,

In this post going to share to code-sample for the hide gridview column at run-time using asp.net with c#

Table of Contents

1. In the 1st steps, code-sample for collection class for returns dataSet.
2. In the 2nd steps, code-sample for bind the grid view and hide row from grid view at the run time.

In the step 1st

/// <summary>
/// Collection Class is used to return dataset.
/// </summary>
public class CollectionClass
{
    /// <returns>DataSet</returns>
    public DataSet GetVideofile()
    {
        DataSet dsVideo = null;
        string spNamehere = "sp_getCWVideos";
        Hashtable paramTable = new Hashtable();
        dsVideo = System.Web.DataAccess.ExecuteSP(spNamehere, paramTablehere);
        return dsVideo;
    }
}

In the step 2nd

/// <summary>
/// Page load event is used to bind the data sourses.
/// </summary>
protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        CollectionClass objcollcls = new CollectionClass();
        GridViewID.DataSource = objcollcls.GetVideofile();
        GridViewID.DataBind();

        GridViewID.HeaderRow.Cells[5].Visible = false;
        foreach (GridViewRow objgvr in GridViewID.Rows)
        {
            objgvr.Cells[5].Visible = false;
        }
    }
    catch (Exception ex)
    {
        lblMessagetext.Text = ex.Message;
    }
}


ANIL SINGH

Hey! I'm Anil Singh. I author this blog. I'm Active Blogger, Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
http://www.code-sample.com
http://www.code-sample.xyz

You Might Also Like
Post a Comment
www.code-sample.com/. Powered by Blogger.