Solved

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

Posted on 2009-05-19
4
243 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

772 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

13 Experts available now in Live!

Get 1:1 Help Now