C#里datatable数据拆分
>>>>每5000条建立一张表>>>>
DataSet dtm= new DataSet();
var dtm_length = dtm.Tables[0].Rows.Count / 5000;
List<DataTable> list = new List<DataTable>();
for (int i = 0; i < dtm_length; i++)
{
DataTable dtm_new = new DataTable();
dtm_new = dtm.Tables[0].AsEnumerable().Skip(i * 5000).Take(5000).CopyToDataTable().Copy();
dtm_new.TableName = "sw_CGFP_b";
list.Add(dtm_new);
}
>>>>剩余不足5000条的建立一张表>>>>
DataTable dtm_new1 = new DataTable();
dtm_new1 = dtm.Tables[0].AsEnumerable().Skip(dtm_length * 5000).Take(dtm.Tables[0].Rows.Count - dtm_length * 5000).CopyToDataTable().Copy();
dtm_new1.TableName = "sw_CGFP_b";
list.Add(dtm_new1);
string [] dtm_list =new string [list.Count];
for (var i = 0; i < list.Count; i++)
{
dtm_list[i] = JEDConvertTools.ObjectToJson(list[i]);
}
动态添加option
var field_input = $("#stock_id");//得到元素节点
$(field_input).html("");//清空原来内容
$("#stock_id option").remove();
$("#stock_id").append("<option value=''></option>");
$.each(data, function (key, value) {
if (data[key].stock_id != null && data[key].stock_name != "") {
$("#stock_id").append("<option value='" + data[key].stock_id + "'>" + data[key].stock_id + "||" + data[key].stock_name + "</option>");
//添加新内容
}
});
重画
int line1 = cb_count - 4 > 0 ? 4 : cb_count;
int line2 = cb_count - 4 > 0 ? cb_count : 0;
<ul class="pricing_table row">
@for (int i = 0; i < line1; i++)
{
<li class="price_block col-md-3">
<h3>@Model.class_basic[i].pp_name</h3>
<div class="price success">
<div class="price_figure">
@Model.class_basic[i].note
</div>
</div>
<div class="footer">
<a href="javascript:" class="btn btn-primary" MyType = "check" Id="@Model.class_basic[i].pp_no"><i class="fa fa-eye"></i> 查看</a>
</div>
</li>
}
</ul>
<ul class="pricing_table row">
@if (line2 != 0)
{
for (int i = 4; i < line2; i++)
{
<li class="price_block col-md-3">
<h3>@Model.class_basic[i].pp_name</h3>
<div class="price danger">
<div class="price_figure">
@Model.class_basic[i].note
</div>
</div>
<div class="footer">
<a href="javascript:" class="btn btn-primary" MyType = "check" Id="@Model.class_basic[i].pp_no"><i class="fa fa-eye"></i> 查看</a>
</div>
</li>
}
}
</ul>
关闭页面
<button type="button" class="btn btn-danger"><i class="fa fa-remove"></i> <a href="javascript:window.opener=null;window.close();" class="btn btn-danger">关闭</a></button>
数组
var zgbhArr = [];
zgbhArr.push(data.zgbh, data.zgxm)
对象
var obj = {};
obj[data.zgbh] = data.zgxm;
后台正则
string pattern = @"^[a-zA-Z]+$";
Regex regex = new Regex(pattern);
if (regex.IsMatch(dr["loc_id"].ToString().Substring(0, 1)))
{
dr.Delete();
}