Showing posts with label GridView. Show all posts
Showing posts with label GridView. Show all posts

Thursday, March 13, 2014

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



I have gotten this error several times:

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

Each time I forget the solution and after I fix it I eventually forget why I was getting it.  This time is not different.  I can't remember why it started happening, but the solution is to create a method like this.

public override void VerifyRenderingInServerForm(Control control)

{
 
/* Verifies that the control is rendered */
}

Thursday, February 7, 2008

Formating Dates in the GridView

I set up a bound GridView. I had several bound fields. A couple of the field were dates. The data source was a date time field. I did not want the time portion, so I used
DataFormatString="{0:MM/dd/yyyy}" on the BoundFields. On my development box it stripped off the time. When I deployed to the server it was still showing the times.

The solution was to add HtmlEncode="False" to the bound fields.