?
Solved

bind a datagrid to a web service dataset C#

Posted on 2006-06-05
5
Medium Priority
?
583 Views
Last Modified: 2008-02-01
How do you bind a datagrid to a web service that returns a dataset.
0
Comment
Question by:carter_jl
  • 3
  • 2
5 Comments
 

Author Comment

by:carter_jl
ID: 16837846
I have a webservice that returns a dataset. How can bind this dataset to a datagrid in a web application?
0
 
LVL 16

Accepted Solution

by:
Edwin_C earned 2000 total points
ID: 16840969
It should makes no difference in binding a dataset to a datagrid when your dataset is returned from a webservice or directly from database.

MyWebService webService = new MyWebService();
DataSet ds = webService.GetMyDataSet();  //GetMyDataSet is the method returning your dataset
MyDataGrid.DataSource=ds.Tables[0];  //bind the first table to the datagrid. alternative you can specify the table name
MyDataGrid.DataBind();

I hope I understand your question correctly.

Edwin
0
 

Author Comment

by:carter_jl
ID: 16841695
Service1 webservice = new Service1();
                  DataSet ds = webservice.getAllEmployees();
                  DataGrid1.DataSource = ds.Tables[0];
                  DataGrid1.DataBind();

This is the code I use to bind the datagrid. The only thing I get is the columns. There are no rows returned. What could be causing this? I don't think its the service method because I tested the service by itself.
0
 
LVL 16

Expert Comment

by:Edwin_C
ID: 16842101
The only explanation I can think of is that your ds.Tables[0] contains no rows.  You can show the value of ds.Tables[0].Rows.Count in a label or in debug mode to see whether it contains rows.

Good luck
Edwin
0
 

Author Comment

by:carter_jl
ID: 16842139
You are correct it contains on rows, which is weird because when i invoke my service, (by itself) I can see the rows returned.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month15 days, 9 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question