已经获取了数据源 现在要在每条数据后面都添加一行
//添加行
for (int i = 0; i <= GridViewList.Rows.Count - 1; i++)
{
DataRow row = ds.Tables[0].NewRow();
Label lblstrKOSTL = (Label)GridViewList.Rows[i].FindControl("lblstrKOSTL");
Label lblstrHKONT = (Label)GridViewList.Rows[i].FindControl("lblstrHKONT");
Label lblstrBUKRS = (Label)GridViewList.Rows[i].FindControl("lblstrBUKRS");
Label lblstrHKONTName = (Label)GridViewList.Rows[i].FindControl("lblstrTxt20");
row[0] = i + 1;
row[1] = lblstrBUKRS.Text;
row[2] = lblstrKOSTL.Text;
row[3] = lblstrHKONT.Text;
row[4] = lblstrHKONTName.Text;
ds.Tables[0].Rows.Add(row);
}这种写法 添加的行全部都显示在最后 大家有什么好办法?
//添加行
for (int i = 0; i <= GridViewList.Rows.Count - 1; i++)
{
DataRow row = ds.Tables[0].NewRow();
Label lblstrKOSTL = (Label)GridViewList.Rows[i].FindControl("lblstrKOSTL");
Label lblstrHKONT = (Label)GridViewList.Rows[i].FindControl("lblstrHKONT");
Label lblstrBUKRS = (Label)GridViewList.Rows[i].FindControl("lblstrBUKRS");
Label lblstrHKONTName = (Label)GridViewList.Rows[i].FindControl("lblstrTxt20");
row[0] = i + 1;
row[1] = lblstrBUKRS.Text;
row[2] = lblstrKOSTL.Text;
row[3] = lblstrHKONT.Text;
row[4] = lblstrHKONTName.Text;
ds.Tables[0].Rows.Add(row);
}这种写法 添加的行全部都显示在最后 大家有什么好办法?
http://bbs.csdn.net/topics/390468399?page=1#post-394577749
绑定到dataGridView之前做处理? 怎么处理?
{
DataTable dt = GetOrderReceiptMain().Tables[0]; DataRow dr;
for (int i = dt.Rows.Count - 1; i >= 0; i--)
{
for (int j = 0; j < rowNum; j++)
{
dr = dt.NewRow();
for (int k = 0; k < sameNum; k++)
{
dr[k] = dt.Rows[i][k].ToString();
}
dt.Rows.InsertAt(dr, i + 1);
}
}
gridstocksaleaffirmlist.DataSource = dt;
gridstocksaleaffirmlist.DataBind();
}