是我画的,我只能做到这种程度,再往下做就不会了。
string strSql = "SELECT * FROM ClientInfo";
SqlConnection cn = new SqlConnection("server=.;uid=sa;pwd=;database=Pact");
SqlDataAdapter da = new SqlDataAdapter(strSql,cn);
DataTable dt = new DataTable();
da.Fill(dt);
DataTable dn= new DataTable();
dn.Columns.Add("ColumnName", typeof(string));
for (int i=0; i < dt.Rows.Count; i++)
dn.Columns.Add("Column" + (i+1).ToString(), typeof(string));
foreach(DataColumn dc in dt.Columns)
{
DataRow dnr = dn.NewRow();
dnr["ColumnName"] = dc.ColumnName;
for (int i=0; i < dt.Rows.Count; i++)
{
dnr[i+1] = dt.Rows[i][dc].ToString();
}
dn.Rows.Add(dnr);
}
DataGrid1.DataSource=dn.DefaultView;
DataGrid1.DataBind();
怎么才能在一个大项里面包含小项阿?
[此贴子已经被作者于2007-4-11 11:34:27编辑过]