public void loaddynamicgrid()
{
DataTable dt = new DataTable();
DataColumn dc;
DataRow dRow;
dc = new DataColumn("Date", typeof(DateTime));
dt.Columns.Add(dc);
dc = new DataColumn("Name", typeof(Int64));
dt.Columns.Add(dc);
SqlDataAdapter da = new SqlDataAdapter("select * from Tbl_Emp", Sqlconnectionstring);
DataSet ds = new DataSet();
da.Fill(ds);
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
dRow = dt.NewRow();
dt.Rows.Add(dRow);
dt.Rows[i][0] = ds.Tables[0].Rows[i]["date"].ToString();
dt.Rows[i][1] = ds.Tables[0].Rows[i]["name"].ToString();
}
}
0 comments:
Post a Comment