DataGrid dg = new DataGrid();
dg.DataSource = ds.Tables["db"];
dg.DataBind();
//实例化一个HtmlTextWriter的类
System.Text.StringBuilder strb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter( strb );
System.Web.UI.HtmlTextWriter htw = new HtmlTextWriter( sw );
//执行控件的render并输出到HtmlTextWriter里
dg.RenderControl( htw );
string s = strb.ToString();
dg.DataSource = ds.Tables["db"];
dg.DataBind();
//实例化一个HtmlTextWriter的类
System.Text.StringBuilder strb = new System.Text.StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter( strb );
System.Web.UI.HtmlTextWriter htw = new HtmlTextWriter( sw );
//执行控件的render并输出到HtmlTextWriter里
dg.RenderControl( htw );
string s = strb.ToString();