DataSet.Tables[0].Rows[0]["NoFound"] = "No Checked,Please Wait!";
如上:DataSet中本是一个空的,直接New的。 现在要在里面加一个key为 notfound,值为"No Checked,Please Wait!"的东东,应该怎么弄呀?
------解决方案--------------------------------------------------------
这样写:
DataSet ds = new DataSet();
ds.Tables.Add();
ds.Tables[0].Columns.Add("NoFound");
ds.Tables[0].Rows.Add("No Checked,Please Wait!");
------解决方案--------------------------------------------------------
- C# code
//①Create a DataSet DataSet ds = new DataSet(); //②Create a DataTable DataTable dt = new DataTable("Table_AX"); //③Add columns for DataTable //Method 1 dt.Columns.Add("NoFound", System.Type.GetType("System.String")); //④Add rows for DataTable //★Initialize the row DataRow dr = dt.NewRow(); dr["NoFound"] = "No Checked,Please Wait!"; dt.Rows.Add(dr); //★Doesn't initialize the row DataRow dr1 = dt.NewRow(); dt.Rows.Add(dr1); //⑤Fill DataSet ds.Tables.Add(dt);