GRID VIEW EVENT NOT GETTING TRIGGERED

Ashish Pandey

Total Post:128

Points:898
Posted by  Ashish Pandey
 806  View(s)
Ratings:
Rate this:

I have a gridview created dynamically , now i am trying to do edit each column by keeping a link button. But the rowdatabound event is not getting triggered.Where i might have gone wrong? Below is my code :

 

dtValues = gObj.GetAllDocumentsHistoryList();

            dtHeader = gObj.GetAllHeaderList();

            GridView gvEmployee = new GridView();

            gvEmployee.ShowHeaderWhenEmpty = true;

            gvEmployee.EmptyDataText = "Sorry No History Records Found !!!!!!!";

            gvEmployee.AutoGenerateColumns = false;

            for (int i = 0; i < dtValues.Columns.Count; i++)

            {

                string name = dtValues.Columns[i].ColumnName.ToString();

                BoundField boundfield = new BoundField();

                boundfield.DataField = dtValues.Columns[i].ColumnName.ToString();

 

                for (int j = 0; j < dtHeader.Rows.Count; j++)

                {

                    if (dtHeader.Rows[j]["ColCode"].ToString() == dtValues.Columns[i].ColumnName.ToString())

                    {

                        boundfield.HeaderText = dtHeader.Rows[j]["ColName"].ToString();

                        if (boundfield.HeaderText.Contains("Date") || boundfield.HeaderText.Contains("DocExpiry"))

                        {

                            boundfield.DataFormatString = "{0:dd/MMM/yyyy}";

                        }

                    }

                    else if (dtValues.Columns[i].ColumnName.ToString() == "Last Modified Date")

                    {

                        boundfield.HeaderText = "Last Modified Date";

                        boundfield.DataFormatString = "{0:dd/MMM/yyyy}";

                    }

                }

                gvEmployee.Columns.Add(boundfield);

            }

  1. Pravesh Singh

    Post:412

    Points:2888
    Re: Grid view event not getting triggered

    Hi Ashish, 

    gvEmployee.DataSource = dtValues;

    gvEmployee.RowDataBound += new GridViewRowEventHandler(gvEmployee_RowDataBound);

    gvEmployee.DataBind();

    gvEmployee.Width = new Unit("90%");

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!