下面以DataSet为例子,代码摘自jasmineou的 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(); 相关文章: 2021-08-03 2022-12-23 2021-07-10 2021-06-03 2021-07-13 2021-07-22 2021-07-23