Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2009-05-19
4
Medium Priority
?
259 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:Munawar Hussain
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:
Munawar Hussain earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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:…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

963 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