not show data in grid view after code

Posted by Naveenrohillamca under ASP.NET on 7/3/2011 | Points: 10 | Views : 1308 | Status : [Member] | Replies : 2
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=ROHILLA;Initial Catalog=query;Persist Security Info=True;User ID=sa;Password=123";
con.Open();
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand("select * from Table1 where roll=1", con);

DataSet ds = new DataSet();
da.Fill(ds, "Table1");
dataGridView1.DataSource = ds;
after doing this grid view don't show data pls help me to see code in grid view






Responses

Posted by: Rajesh_parbat on: 7/3/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,

Add the following after dataGridView1.DataSource = ds;

dataGridView1.DataBind();



Naveenrohillamca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenrohillamca on: 7/3/2011 [Member] Starter | Points: 25

Up
0
Down
HI..........THANKS 4 HELP ME........

PLS PROVIDE ME A EBOOK FOR ASP.NET 3.5
THANKS

Naveenrohillamca, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response