C# DataTable??????÷?????
???????????? ???????[ 2016/7/19 10:40:39 ] ??????????????????? .NET
??????11??Sort row
????dt.DefaultView.Sort = "ID ??Name ASC";
????dt=dt.DefaultView.ToTable();
??????12??Bind DataTable
????//?????????DefaultView
????gvTestDataTable.DataSource = dt;
????gvTestDataTable.DataBind();
??????13??judge the DataTable’s Column name is a string
????//?ж?????????????DataTable??????
????dtInfo.Columns.Contains("AX");
??????14??DataTable convert to XML and XML convert to DataTable
protected void Page_Load(object sender?? EventArgs e)
{
DataTable dt_AX = new DataTable();
//dt_AX.Columns.Add("Sex"?? typeof(System.Boolean));
//DataRow dr = dt_AX.NewRow();
//dr["Sex"] = true;
//dt_AX.Rows.Add(dr);
string xml=ConvertBetweenDataTableAndXML_AX(dt_AX);
DataTable dt = ConvertBetweenDataTableAndXML_AX(xml);
}
public string ConvertBetweenDataTableAndXML_AX(DataTable dtNeedCoveret)
{
System.IO.TextWriter tw = new System.IO.StringWriter();
//if TableName is empty?? WriteXml() will throw Exception.
dtNeedCoveret.TableName=dtNeedCoveret.TableName.Length==0?"Table_AX":dtNeedCoveret.TableName;
dtNeedCoveret.WriteXml(tw);
dtNeedCoveret.WriteXmlSchema(tw);
return tw.ToString();
}
public DataTable ConvertBetweenDataTableAndXML_AX(string xml)
{
System.IO.TextReader trDataTable = new System.IO.StringReader(xml.Substring(0?? xml.IndexOf("<?xml")));
System.IO.TextReader trSchema = new System.IO.StringReader(xml.Substring(xml.IndexOf("<?xml")));
DataTable dtReturn = new DataTable();
dtReturn.ReadXmlSchema(trSchema);
dtReturn.ReadXml(trDataTable);
return dtReturn;
}
??????15????DataTable????в??????DataTable??
????????1??
????// <summary>
????// ???DataTable?е????????μ?DataTable
????// </summary>
????// dt ???????DataTable
????// condition ????????
????DataTable newdt = new DataTable();
????newdt = dt.Clone(); // ???dt ????????????? dt ???????????????????
????DataRow[] rows = dt.Select(conditions); // ??dt ?в????????????????
????foreach (DataRow row in rows) // ?????????????dt?У?
????{
????newdt.Rows.Add(row.ItemArray);
????}
????????2??
????DataTable newdt = new DataTable();
????newdt=dt.Clone();
????DataRow[] dr = dt.Select(condition);
????for(int i=0;i<dr.Length;i++)
????{
????newdt.ImportRow((DataRow)dr[i]);
????}
????????3??
????DataTable newdt = new DataTable();
????dt.DefaultView.RowFilter = "conditions";
????newdt =dt.DefaultView.ToTable();
??????16?????DataTable?е???:
???????DataTable?е??????????????DataTable.Rows.Remove(DataRow dr)??DataTable.Rows.RemoveAt(i)??DataRow.Delete()??
???????DataTable?е?????????????????????????????
????1????for????????????????????????????????DataTable.Rows.RemoveAt(i)????
????2????DataTable??Select?????????÷???????????????????
????3??Delete()??????datatable.AccepteChanges()??????????????????Delete()????????е?????????????????????datatable.RejectChanges()???????????????????????????У???????????Delete()????????AccepteChanges()????????????
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???????C#?е?StringC# Socket???????????????????C#?????????????????????????C#???????C#????????????Log4net??????δ????C#?????????????C#?????????????????C#???????????????C#????????????????C#7 ?е?Tuple??????C#??TypeScript - GeneratorC# ?????????細(xì)??????????C#?е???н???C#??MySQL?????????μ??Ч?????д??C#????C++??dll???C#??VS2010????е??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????