Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using asp.net gridview it was required to show details in vertical format i did that and there is one comment row on click of which im giving option to edit the comment text but now the problem is when i double click anywhere in the grid view row it is giving option to edit i want my first column should be disable and only comment row should be editable and one more thing im using
AutoGenerateColumns="true"
becase i have 150 columns and i cant format each and every column
please suggest sumthing
thanks in advance

What I have tried:

protected void gvDetails_DataBound(object sender, EventArgs e)
   {

       
       int i;
      for (i = 0; i <= gvDetails.Rows.Count - 1; i++)
      {
          gvDetails.Rows[i].Cells[0].Enabled  = false;
      }

       
   }



protected void gvDetails_RowDataBound(object sender, GridViewRowEventArgs e)
  {
      if (e.Row.RowType == DataControlRowType.DataRow)
      {
          e.Row.Attributes["ondblclick"] = Page.ClientScript.GetPostBackClientHyperlink(gvDetails, "Edit$" + e.Row.RowIndex);
          e.Row.Attributes["style"] = "cursor:pointer";
      }



  }
  protected void gvDetails_RowEditing(object sender, GridViewEditEventArgs e)
  {
      gvDetails.EditIndex = e.NewEditIndex;
      //this.BindGrid();
     // gvDetails.Columns[2].Visible = true;
  }
Posted
Updated 4-Aug-20 2:59am

1 solution

dataGridView1.Columns["CompanyName"].ReadOnly = true;
 
Share this answer
 
Comments
Member 12966735 21-Apr-17 0:51am    
thank you for your answer but im using asp.net gridview with Autogeneratecolumn property true this is nit working

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900