createDataSource, and add new rows on the datagrid to be filled out.

来源:互联网 发布:范冰冰用什么直播软件 编辑:程序博客网 时间:2024/04/28 05:31

DataTable createDataSource()
  {
   
    string strConn="server=localhost;database=LIMS;uid=sa;pwd=sa;";
    string strSql = "select * from arrear where guestName = '" + id2 + "'";
    SqlDataAdapter da = new SqlDataAdapter(strSql,new SqlConnection(strConn));
    DataSet ds = new DataSet();
    da.Fill(ds);

    DataSet ds1 = ds.Clone();
    dt = ds1.Tables[0];
    //
    int i,k=0 ;
    for(i=0;i< ds.Tables[0].Rows.Count;i++)
     dt.ImportRow(ds.Tables[0].Rows[i]);
    Session["ItemIndex"] = (object)(i);
    for(int j=(i%10);j<10;j++,k++)
    {
     dt.Rows.Add(dt.NewRow());    
     dt.Rows[i+k][3] = "null";//set the column's style
    }
    return dt; 
   
  
  }