You must use
DataBind()
, after assigning datasource to gridview. See the code below,
List<string> adds = new List<string>();
SqlDataAdapter da = new SqlDataAdapter("seLECT YEAR(startdt) AS [Year],MONTH(startdt) AS [Month], DAY(startdt) as [day],cast(startdt as datetime) as [datetime], COUNT(*),ipaddress from visit Group By YEAR(startdt), MONTH(startdt),day(startdt),startdt,ipaddress", con);
SqlCommandBuilder cb = new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds, "normalpackage");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
adds.Add(ds.Tables[0].Rows[i].ItemArray[0].ToString());
}
dataGridView1.DataSource = ds;
dataGridView1.DataBind();
bindingSource1.DataSource = ds;
dataGridView1.Visible = true;</string></string>
-KR