合併Gridview表頭
posted @ 2009-11-06 10:50 hambywu 阅读(121) 评论(0) 编辑
posted @ 2009-11-06 10:50 hambywu 阅读(121) 评论(0) 编辑
private DataTable ReadGridView()
{
DataTable newDataTable = new DataTable("Table1");
newDataTable = CreateTable();

for (int i = 0; i < this.gv_productlist.Rows.Count; i++)
{
GridViewRow gRow = gv_productlist.Rows[i];
DataRow newrow = newDataTable.NewRow();
// newRow[""] = L_ModelType
newrow["ProjectGuid"] = L_guidvalue.Text;
newrow["ProdGuid"] = ((Label)gRow.FindControl("L_prodguid")).Text;
newrow["fldNum"] = ((TextBox)gRow.FindControl("txt_fldnum")).Text;
newrow["fldEndDate"] = ((Label)gRow.FindControl("L_EndDate")).Text; ; ;
newrow["fldModelType"] = ((Label)gRow.FindControl("L_ModelType")).Text;
newrow["fldModelTypeSj"] = ((TextBox)gRow.FindControl("txt_fldModelTypeSj")).Text;
newrow["ID"] = ((Label)gRow.FindControl("L_NO")).Text;
newDataTable.Rows.Add(newrow);
}
newDataTable.AcceptChanges();
return newDataTable;
}
public void BindList()
{
// DataTable table = CreateTable();
DataTable sTable = new DataTable();
sTable = ReadGridView();
if (id == 0)
{
if (Session[L_guidvalue.Text.Trim()] != null)
{
DataTable tb = new DataTable();
tb = Session[L_guidvalue.Text.Trim()] as DataTable;
//table = Session[L_guidvalue.Text.Trim()] as DataTable;
for (int i = 0; i < tb.Rows.Count; i++)
{
sTable.ImportRow(tb.Rows[i]);
}
}
}
else
{
//如果有session则里面读取
if (Session[L_guidvalue.Text.Trim()] != null)
{
DataTable tb = new DataTable();
tb = Session[L_guidvalue.Text.Trim()] as DataTable;
for (int i = 0; i < tb.Rows.Count; i++)
{
sTable.ImportRow(tb.Rows[i]);
}
}
else
{//如果没有则从库中读取
sTable = GetTableInfo();
}
Session[L_guidvalue.Text.Trim()] = sTable;
}
this.gv_productlist.DataSource = null;
this.gv_productlist.DataSource = sTable;
//this.gv_productlist.PageSize = AspNetPager2.PageSize;
//gv_productlist.PageIndex = AspNetPager2.CurrentPageIndex - 1;
AspNetPager2.RecordCount = sTable.Rows.Count;
this.gv_productlist.DataBind();
//Session[L_guidvalue.Text.Trim()] = null;
}
posted @ 2009-11-06 09:47 hambywu 阅读(256) 评论(0) 编辑
Powered by:
博客园
Copyright © hambywu
