Any Simple Code for binding data with gridview?

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2009
Posts: 3
Reputation: diru is an unknown quantity at this point 
Solved Threads: 0
diru diru is offline Offline
Newbie Poster

Any Simple Code for binding data with gridview?

 
0
  #1
Nov 2nd, 2009
Anyone can help me to give link or website / tutorial about binding data with gridview ??....
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 63
Reputation: love_dude1984 is an unknown quantity at this point 
Solved Threads: 2
love_dude1984 love_dude1984 is offline Offline
Junior Poster in Training
 
0
  #2
Nov 3rd, 2009
Try this:
  1.  
  2. SqlConnection cn = new SqlConnection("Your ConnectionsString here");
  3. SqlCommand cmd = new SqlCommand("Query to Retrieve data from database",cn);
  4. SqlDataAdapter da = new SqlDataAdapter(cmd);
  5. DataSet ds = new DataSet();
  6. da.Fill(ds, "Data");
  7.  
  8.  
  9. gridview.DataSource = ds.Tables[0];
  10. gridview.DataBind();

define the variables globally if u want to use them more thn once.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 3
Reputation: diru is an unknown quantity at this point 
Solved Threads: 0
diru diru is offline Offline
Newbie Poster

its working!

 
0
  #3
Nov 3rd, 2009
already try the code,

very simple and it work the way i wanted, Thanks love_dude1984.....
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 354 | Replies: 2
Thread Tools Search this Thread



Tag cloud for ASP.NET
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC