Solved

Using a function to return a data set and then bind it to a gridview

Posted on 2009-05-19
4
244 Views
Last Modified: 2013-11-25
I have a function that resides in a class, in my aspx.vb file I want to call the function on a button click event.  The function invokes a web service and will return y or x depending on the input.  My question is how can I bind y or x to a gridview.  

so In my asp.vb file I have:        
LimitByCompanyCode.GetLSODataset(txtBeginDate.Text, txtEndDate.Text, radioSelection.SelectedValue)

'So how can I get whatever the function returns and show that in my gridview?
0
Comment
Question by:DotNetNooby
  • 2
4 Comments
 
LVL 12

Expert Comment

by:needo_jee
ID: 24425908
it seems your webservice returns a dataset so you should call it like this


dim ds as DataSet= LimitByCompanyCode.GetLSODataset(txtBeginDate.Text, txtEndDate.Text, radioSelection.SelectedValue)

if ds.tables.count > 0 then

myGridView.DataSource=Ds.tables(0)
myGridView.DataBind()

end if

-thanks
0
 

Author Comment

by:DotNetNooby
ID: 24426025
I've been trying that... I get the following error: Value of type 'System.Data.DataTable' cannot be covnerted to 'System.Data.DataSet'.
0
 
LVL 9

Expert Comment

by:tculler
ID: 24426813
I'm gunna take a wild guess and say your function "LimitByCompanyCode.GetLSODataset" returns a System.Data.DataTable, note a System.Data.DataSet. Check into that. If it does return a table, either change it to a DataSet, or, if that's not appropriate, declare a new DataSet and add the table to it. That will look like:

Dim someSet As New DataSet;
someSet.Tables.Add(LimitByCompanyCode.GetLSODataset( /*Overloads*/ ));

Hope that helps,
Nate
0
 
LVL 12

Accepted Solution

by:
needo_jee earned 500 total points
ID: 24428052
I see,

in 2.0 it allows to return a datatable. (however, in 1.1 there was restriction that you can only return a dataset)

so try

dim dt as DataTable = LimitByCompanyCode.GetLSODataset(txtBeginDate.Text, txtEndDate.Text, radioSelection.SelectedValue)


-thanks
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now