Empty gridview

Reply

Join Date: May 2008
Posts: 5
Reputation: l1985 is an unknown quantity at this point 
Solved Threads: 0
l1985 l1985 is offline Offline
Newbie Poster

Empty gridview

 
0
  #1
Nov 23rd, 2008
Hello
I'm making a wabsite with a gridview(so far..)
but,when i try to fill with a dataset ...nothing ,i can't see no data
and my dataset is never empty ,it contains data .I ran some debugs and the dataset reads correctly from the sql server database
here's the code
  1.  
  2. DataSet ds = cat.GetAll("toto", "toto1");
  3. GridPontosInteresse.DataSource = ds;
  4. GridPontosInteresse.DataBind();
  5.  
  6.  
  7. public DataSet GetAll(string user, string pass)
  8. {
  9.  
  10. StatusEnum en = Helper.ValidateUser(user, pass);
  11. if (en.Equals(StatusEnum.OK))
  12. {
  13. //
  14. SqlConnection conn = new SqlConnection(Helper.CONN);
  15. return Helper.GetAllFromTable(conn, "Pontos_interesse");
  16. }
  17. static public DataSet GetAllFromTable(SqlConnection conn, string table ){
  18. string strsql = "SELECT * FROM [" + table+"];";
  19. SqlDataAdapter da = new SqlDataAdapter(strsql , conn); SqlCommandBuilder cmdBldr = new SqlCommandBuilder(da);
  20. da.Fill(ret,"cc");


Thanks
Reply With Quote Quick reply to this message  
Join Date: Sep 2007
Posts: 95
Reputation: reach_yousuf is an unknown quantity at this point 
Solved Threads: 17
reach_yousuf reach_yousuf is offline Offline
Junior Poster in Training

Re: Empty gridview

 
0
  #2
Nov 24th, 2008
If i understand correctly, you need to instantiate your dataset

VB code

dim ds as new dataset

C# (Pls. correct the syntax if its wrong)

dataset ds = new dataset
Yousuf
Software Developer
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: l1985 is an unknown quantity at this point 
Solved Threads: 0
l1985 l1985 is offline Offline
Newbie Poster

Re: Empty gridview

 
0
  #3
Nov 24th, 2008
this method instanciates the dataset
  1. static public DataSet GetAllFromTable(SqlConnection conn, string table )
  2. {
  3. DataSet ret = new DataSet();
  4. string strsql = "SELECT * FROM [" + table+"];";
  5. SqlDataAdapter da = new SqlDataAdapter(strsql , conn);
  6.  
  7. SqlCommandBuilder cmdBldr = new SqlCommandBuilder(da);
  8.  
  9.  
  10. da.Fill(ret,"cc");
  11.  
  12. ....
  13. }

just forgot to put it in the message
so the dataset works ok
Last edited by peter_budo; Nov 28th, 2008 at 1:08 pm. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 5
Reputation: l1985 is an unknown quantity at this point 
Solved Threads: 0
l1985 l1985 is offline Offline
Newbie Poster

Re: Empty gridview

 
0
  #4
Nov 24th, 2008
found it

i created a new gridview and tried to bind the data to it ,ad it worked so,the problem was in the gridview(maybe some property set to false)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 1466 | Replies: 3
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