(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()方法确认删除。