1.将DataTable中的某些值添加到一个新的DataTable中,其中新的DataTable的列(结构)与前一DataTable保持一致
public void loadGvList()
{
string laterMin = this.txtNoTimeMin.Value;
if (laterMin == "" || !cbISAll.Checked)
laterMin = "0";
ScheduleInfoManage siMan = new ScheduleInfoManage();
DataTable dt = siMan.NoTimeExamCount(txtSTime.Value.Replace("-", ""), txtEtime.Value.Replace("-", ""), Convert.ToInt32(ddlStyle.SelectedValue), Convert.ToInt32(ddlJF.SelectedValue), ddlKSBQ.SelectedValue, laterMin);
DataTable newdt =dt.Copy();
newdt.Clear();
if(dt.Rows.Count>0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
//判断是否已经登记
if (Convert.ToInt32(dt.Rows[i]["ExamState"]) == 0 || Convert.ToInt32(dt.Rows[i]["ExamState"]) == 10)
{
//newdt.Rows.Add(dt.Rows[i]);
newdt.ImportRow(dt.Rows[i]);
}else
{
newdt.ImportRow(dt.Rows[i]);
}
}
}
this.GVContentList.DataSource = newdt;
this.GVContentList.DataBind();
}
2.将Html中的颜色转化为.net后台代码的颜色(System.Drawing.Color)
e.RowBackColor=System.Drawing.ColorTranslator.FormHtml("#eef2f6")
3.如何将"yyyymmdd"(20140908)转化为时间类型
System.IFormatProvider format = new System.Globalization.CultureInfo("zh-CN", true);
DataTime dtime=DateTime.ParseExact("20140908",""yyyyMMdd", format");