Control ‘GridView’ of type ‘GridView’ must be placed inside a form tag with runat=server.

Leave a comment

Please add below functions in code-behind cs file.

  public override void VerifyRenderingInServerForm(Control control)
/* Confirms that an HtmlForm control is rendered for the specified ASP.NET
server control at run time. */

public override bool EnableEventValidation
get { return false; }
set { /*Do nothing*/ }


Add an assembly (.dll) to the GAC manually – .NET

Leave a comment

Situation: While Publishing ASP.NET files onto the remote server there will be no visual studio tools like gacutil.exe. So we can get doubt how can we add assemblies into gac folder (C:\windows\assembly\) without using gac. Here is the solution.


1) Go to local Security Policy in windows 7.



2) Goto Local Policies ——> Security Options—> User Account Control: Run All Administrators in Admin Approval Mode






3) By Default it will be Enabled . Disable it and Add the dlls into C:\windows\Assembly\


UAC Enable

UAC Enable

4) After adding again enable it and enjoy !!!



Access Denied – Read or Write Permissions for a folder in IIS


Situation: One of my friend written an application where the image need to upload into a folder which is in IIS a virtual directory and also he wants to access that image.
But in the process when he is access the image in that folder he is getting an error like “Access Denied”.
Since they deployed the application through IIS. We need to give that particular folder Read/Write Access for  IIS_IUSRS users group.

Passed 70-515: Web Applications Development with Microsoft .NET Framework 4

Leave a comment

I just passed 70-515 Microsoft Certification today.

Now I am MCTS.

Main concentration is on:

  1. MVC architecture
  2. Ajax and Jquery Scripting
  3. Usage of different controls
  4. Caching
  5. Page life cycle Load, pre-init.
  6. State Management etc

Some are easy and others gave my brain to think in answering questions on Jquery and MVC. Need to concentrate.
Happy that Microsoft is supporting Jquery using it we can create many visual effects similar to Flash.

If you are also interested in applying for 70-515 I recommend to follow Mr.Niall Merrigan’s link on
MCTS Web Applications .NET 4

Follow: (70-515) – Objectives with MSDN links.

Under Creative Commons License: Attribution

Disabling some of the Textboxes in gridview edit

1 Comment

Situation: You need some text boxes disable when gridview is in edit mode.


1) Bind the Data without Sqldatasource Control
2) In Row Editing write the code:

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
GridView1.EditIndex = e.NewEditIndex;
TextBox tx_chdets = (TextBox)GridView1.Rows[e.NewEditIndex].FindControl(“TextBox1”);


Full gridvalues insert into database

Leave a comment

In some situations we must insert a bunch of data into database table.

Just when we done some entry every entry must first go to gridview after all the entries completion we will push all the data by single click.

For this we need a run-time datatable:

Here is the code:

1) Decalare a Datatable globally.

DataTable dt1;

2) In the event you like place this code:

DataSet ds2 = new DataSet();

if (Session[“dt1”] != null)

dt1 = Session[“dt1”] as DataTable;
dt1 = new DataTable();


DataRow dr = dt1.NewRow();

dr[“Name”] = TextBox1.Text;
dr[“Rollno”] = TextBox2.Text;


Session[“dt1”] = dt1;
GridView1.DataSource = dt1;

3) In the aspx page take a gridview
with boundfields as name and Rollno
4) For Inserting all the gridview values write foreach in button_click event.

foreach (GridViewRow gvr in GridView1.Rows)
string name1 = gvr.Cells[0].Text;
string roll = gvr.Cells[1].Text;

string str = “Data Source=RADHE;Initial Catalog=mnc_site;User ID=sa;Password=admin123”;
SqlConnection conn = new SqlConnection(str);


string insqry = “insert into testing(Name,Rollno) values (@Name,@Rollno)”;

SqlCommand cmd = new SqlCommand(insqry, conn);

cmd.Parameters.Add(“@Name”, SqlDbType.VarChar).Value = name1 ;
cmd.Parameters.Add(“@Rollno”, SqlDbType.VarChar).Value = roll ;



Any doubts mail me

Storing a image using

Leave a comment

Hi, Use this code to store an image in the online server.

Before doing that we must give Permisiions to the folder in which you want to store Images.

Give Read and Write Permissions.

You must use fileupload control to do this:

Here is the code:

string extn =    System.IO.Path.GetExtension(FileUpload1.FileName);

if ((extn == “.jpg”) || (extn == “.gif”) || (extn == “.png”) || (extn == “.jpeg”))
path = Server.MapPath(“~/Documents”) + “//” + FileUpload1.FileName;

string script = “alert(‘Document Uploaded Successfully…’);”;
Page.ClientScript.RegisterStartupScript(this.GetType(), “str”, script, true);

string script = “alert(‘Invalid File Format…’);”;
Page.ClientScript.RegisterStartupScript(this.GetType(), “str”, script, true);
Any doubts Mail Me at

Older Entries

%d bloggers like this: