Hiding Columns in GridView when AutoGenerateColumns is True


If we have set AutoGenerateColumns property of the GridView as true and binding it to a data source, we will not be able to remove columns from it using the Remove or RemoveAt functions of Columns.

myGridView.Columns.Remove or RemoveAt

So to remove the columns we can make use of RowDataBound event.

protected void myGridView _RowDataBound(object sender, GridViewRowEventArgs e){
// hide the second and third column
if (e.Row.RowType == DataControlRowType.DataRow)

if (e.Row.RowType == DataControlRowType.Header)
e.Row.Cells[1].Visible = false;

e.Row.Cells[2].Visible = false;}

Hope it helps!!


The current identity “domain\username” does not have write access to ‘C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files’.

To reslove this error,

i first tried registering ASP.NET 2.0

1. Open a command prompt.
2. Navigate to ‘C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\’
3. Run this: aspnet_regiis.exe -i

Followed by adding the “domain\username” to the “IIS_IUSRS” group.

This resolved the error.

Cannot read configuration file due to insufficient permissions


Was getting this issue in one of my ASP.NET application in IIS 7.

Gave Read Permission to IIS_IUSRS on the site.

This fixed the problem.

Good resources for understanding GridView

Check out these wonderful articles on GridView

http://www.codersource.net/AspNet/ASPNet20/GridviewcontrolinASPNet20.aspx http://www.codersource.net/AspNet/ASPNet20/Aspnet20GridViewcontrolindepth.aspx


And the best one,  a cook book on GridView



Body OnLoad function in content page in ASP.NET


I wanted to certain script to run in the onload of the body for my content page.

To do this we need to do the following

Add an id and runat attribute to the body tag in the MASTER page

<body id=”body” runat=”server”>

And in the Content page’s  page load handler

protected void Page_Load(object sender, EventArgs e)
HtmlGenericControl body = this.Master.FindControl(“body”) as HtmlGenericControl;
body.Attributes.Add(“onLoad”, “alert(‘Hello World’);”);


Server Application Unavailable in ASP.NET 2.0


I was getting this error when trying to open a asp.net 2.0 page.

However other applications developed in asp.net 1.1 were running fine.

Then realized that both of them were using the same Application Pool, so created a new application pool and assigned this new application pool to my asp.net 2.0 application.

That solved the issue.

“An application pool is a process that responds to web requests under IIS. An application pool does not have a setting for what type of ASP.Net applications will be run in it. Instead, it loads the appropriate libraries when an ASP.Net application is loaded in the process. Because the libraries for ASP.Net 1.1 and ASP.Net 2.0 are similar, but not the same, the application pool cannot respond to requests for both types of applications at the same time. This can cause sporadic behavior if you are using the server at the same time as another developer and you have applications using different versions of the framework in the same application pool”


%d bloggers like this: