Solved

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

Posted on 2009-05-19
4
249 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: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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…

751 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