The error is in this line of code
gvDetails.Columns["compname"].Visible = false;
You must have an integer value inside the big brackets []. It is nothing but the index value of the column. Suppose you have five columns A,B,C,D & E. Their index value will be 0,1,2,3 & 4. If you want to hide fourth column for example
compname here (i.e index value = 3), then you will have to modify your code like this
gvDetails.Columns[3].Visible = false;
Hope that helps.