add your datagrid between
<form runat=server>
<asp:datagrid id="MyDataGrid" runat="server" />
</form>see
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q317719
<form runat=server>
<asp:datagrid id="MyDataGrid" runat="server" />
</form>see
http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q317719
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>query</title>
<meta content="Microsoft Visual Studio .NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" runat="server">
<table align="center">
<TR>
<TD style="HEIGHT: 17px"><FONT face="宋体">车牌号码
<asp:DropDownList id="DropDownList_brand_number" runat="server"></asp:DropDownList>
<asp:Button id="button_query" runat="server" Text="查询"></asp:Button></FONT></TD>
</TR>
<TR>
<TD><FONT face="宋体"></FONT></TD>
</TR>
<tr>
<td>
<asp:datagrid id="MyDataGrid" runat="server" AllowPaging="True" PagerStyle-Mode="NumericPages" PagerStyle-HorizontalAlign="Right" OnPageIndexChanged="MyDataGrid_Page" BorderColor="black" BorderWidth="1" GridLines="Both" CellPadding="3" CellSpacing="0" Font-Name="Verdana" Font-Size="8pt" HeaderStyle-BackColor="#aaaadd" AlternatingItemStyle-BackColor="#eeeeee">
<AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
<HeaderStyle BackColor="#AAAADD"></HeaderStyle>
<PagerStyle HorizontalAlign="Right" Mode="NumericPages"></PagerStyle>
</asp:datagrid>
<p style="FONT-SIZE: 9pt"><asp:label id="lblPageCount" runat="server"></asp:label>
<asp:label id="lblCurrentIndex" runat="server"></asp:label><asp:linkbutton id="btnFirst" onclick="PagerButtonClick" runat="server" Font-Name="verdana" CommandArgument="0" ForeColor="navy" Font-size="8pt"></asp:linkbutton>
<asp:linkbutton id="btnPrev" onclick="PagerButtonClick" runat="server" Font-Name="verdana" CommandArgument="prev" ForeColor="navy" Font-size="8pt"></asp:linkbutton>
<asp:linkbutton id="btnNext" onclick="PagerButtonClick" runat="server" Font-Name="verdana" CommandArgument="next" ForeColor="navy" Font-size="8pt"></asp:linkbutton>
<asp:linkbutton id="btnLast" onclick="PagerButtonClick" runat="server" Font-Name="verdana" CommandArgument="last" ForeColor="navy" Font-size="8pt"></asp:linkbutton></p>
</td>
</tr>
</table>
</form>
</body>
</HTML>
http://www.asp.net/Forums/ShowPost.aspx?tabindex=1&PostID=184315or try my method,
<form id="form1" runat=server> instead of calling DataGrid.RenderControl, call form1.RenderControl, then remove the string before and after the datagrid table form1.RenderControl(hw)
dim s = tw.ToString()
s = System.Text.RegularExpressions.Regex.Replace(s,"^.*?(<table.*?</table>).*$","$1",System.Text.RegularExpressions.RegexOptions.IgnoreCase or System.Text.RegularExpressions.RegexOptions.Singleline) Response.Write(s)