Monday, November 28, 2022

Gridview init function ASP.NET C#

init function is used for user roles and for allow AutoGenerateEditButton and paging

  protected void GridView1_Init(object sender, EventArgs e)

        {

            try

            {

                if (Session["AccessType"].ToString() == "ReadOnly" || Session["AccessType"].ToString() == "VO")

                {

                    GridView1.AutoGenerateEditButton = false;

                    GridView1.AutoGenerateDeleteButton = false;

                    //GridView1.AllowPaging = false;

                    HyperLink hl = ((HyperLink)GridView1.FindControl("HyperLink1"));

                    hl.Visible = false;

                    GridView1.PageSize = 100;

                }

            }

            catch { }

        }

No comments:

Post a Comment