Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

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
?
255 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Linux Academy Android App Now Supports Chromecast

We have some fantastic news for our Android fans. We’re so excited to announce that the Linux Academy Android app is now available with Chromecast support. That’s right – simply download the latest update of the Linux Academy App and start casting your favorite course videos!

Question has a verified solution.

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

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

719 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