动态创建DATASET
提示下面这行代码出错!!说Master未实例化
private void btnaddcolumn_Click(object sender, System.EventArgs e)
{
dsUntyped.Tables["Master"].Columns.Add("MasterId",typeof(int));
}//创建一个两个表
private void Button1_Click(object sender, System.EventArgs e)
{
     DataSet dsUntyped = new DataSet("myDS");
     DataTable dtMaster = new DataTable("Master");
     DataTable dtChild = new DataTable("Child");
     dsUntyped.Tables.Add("dtMaster");
     dsUntyped.Tables.Add("dtChild");
     Session["ds"] = dsUntyped;
}//创建列
private void btnaddcolumn_Click(object sender, System.EventArgs e)
{
DataSet dsUntyped = (DataSet)Session["ds"];
dsUntyped.Tables["Master"].Columns.Add("MasterId",typeof(int));
dsUntyped.Tables["Master"].Columns.Add("MasterValue",typeof(string));
dsUntyped.Tables["Child"].Columns.Add("MasterLink",typeof(int));
dsUntyped.Tables["Child"].Columns.Add("ChildID",typeof(int));
dsUntyped.Tables["Child"].Columns.Add("ChildValue",typeof(string));
//
dsUntyped.Tables["Master"].Columns["MasterId"].Caption = "主ID";
dsUntyped.Tables["Master"].Columns["MasterValue"].Caption = "值";
Session["ds"] = dsUntyped;
Bind();
}//创建绑定
private void Bind()
{
DataSet dsUntype = (DataSet)Session["ds"];
dgMaster.DataSource = dsUntype.Tables["Master"].DefaultView;
dgChild.DataSource = dsUntype.Tables["Child"].DefaultView;
this.DataBind();
}