473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Return a DataSet in a button's click event?

this.btnMybtn.Click += new System.EventHandler(this.btnMyBtn_Click);
private DataSet btnMyBtn_Click(object sender, System.EventArgs e)
{
DataSet dtsReportData = ShowReport();
return dtsReportData;
}
I am getting the error:-
Method myfrm.btnShowReport_Click(object, System.EventArgs)' does not match
delegate 'void System.EventHandler(object, System.EventArgs)'

I would like the click event of btnMyBtn to return a DataSet. How can I do
that?

TIA,
Mounil.
Nov 17 '05 #1
5 3538
You need to have it return void

What you need to do is inside the event, do what you need to do with the
dataset. if you look at this line:

this.btnMybtn.Click += new System.EventHandler(this.btnMyBtn_Click);

you're setting the event... You're not setting something equal to
something else... Thus, there's no where to return to.
MounilK wrote:
this.btnMybtn.Click += new System.EventHandler(this.btnMyBtn_Click);
private DataSet btnMyBtn_Click(object sender, System.EventArgs e)
{
DataSet dtsReportData = ShowReport();
return dtsReportData;
}
I am getting the error:-
Method myfrm.btnShowReport_Click(object, System.EventArgs)' does not match
delegate 'void System.EventHandler(object, System.EventArgs)'

I would like the click event of btnMyBtn to return a DataSet. How can I do
that?

TIA,
Mounil.

Nov 17 '05 #2
Hi Benny,
Thanks for your reply.

The error should read:-

Method myfrm.btnMyBtn_Click(object, System.EventArgs)' does not match
delegate 'void System.EventHandler(object, System.EventArgs)'
ShowReport() returns a DataSet. On the click event of
btnMyBtn, I want to pass on the Dataset. Is that posssible to do?

Nov 17 '05 #3
Where do you want to pass the dataset to? Events are functions that
happen because of something, they're not called from somewhere else in
the code (well... they can be, but not in the way other functions are
called, anyway let's not get confused here).

So, it's not possible to return something from an event. If you think
about it, you're clicking on a button - so if you returned, the return
would go to the button click - there's nothing there for data to go to
except your finger on the mouse button, but why would you want a
database injected into your finger? ;)

Basically you should handle what you want to do inside of the event,
either by having the code there, or by calling a function from within
the event.

Mounilk wrote:
Hi Benny,
Thanks for your reply.

The error should read:-

Method myfrm.btnMyBtn_Click(object, System.EventArgs)' does not match
delegate 'void System.EventHandler(object, System.EventArgs)'
ShowReport() returns a DataSet. On the click event of
btnMyBtn, I want to pass on the Dataset. Is that posssible to do?

Nov 17 '05 #4
Hi Benny,
You have been very helpfull.Thank you very much.

---Mounil.

Nov 17 '05 #5

"MounilK" <mo*****@maxit.com.au> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
this.btnMybtn.Click += new System.EventHandler(this.btnMyBtn_Click);
private DataSet btnMyBtn_Click(object sender, System.EventArgs e)
The click event *requires* the following:
private void btnMyBtn_Click(object sender, System.EventArgs e)
{
DataSet dtsReportData = ShowReport();
return dtsReportData;
}
I am getting the error:-
Method myfrm.btnShowReport_Click(object, System.EventArgs)' does not match
delegate 'void System.EventHandler(object, System.EventArgs)'

I would like the click event of btnMyBtn to return a DataSet.


Return a DataSet to where? The caller (the button component) does not expect
a return value. Where do you expect the DataSet to be "returned" to?
Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: John Holmes | last post by:
I have a web interface where the user types in ID's one at a time. After an ID is typed in, a button is clicked and the button click event has code that does a query and returns a data reader and...
4
by: TonyM | last post by:
Hi all, First, Let me say I feel like a complete idiot here, and shamefully come to you for help. I've read and read and can't get this to work in a web application, however in a windows...
5
by: Alastair Anderson | last post by:
I have created a very simple form with which I would like to update a single value in a single row of a database as a proof of concept. The relevant parts of the form are a DBWebTextBox (which...
0
by: Dave | last post by:
Tried posting in the Winform Forum without much luck, so posting here... After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row that is...
5
by: siaj | last post by:
Hello, I have a javascript function for a validation in the HTML page of the asp.Net page.. I call this function in a Savebutton click When the validation fails No postback should happen ( ie...
12
by: Dave | last post by:
I'm relatively new to ASP and .NET and having trouble getting my head round this. I want to read a datset from a database, and display information from one row at a time, using a Next and a...
2
by: Wayne Wengert | last post by:
I have a VB App (VSNET 2003) in which, during form load, I create a dataset (ds1) and then populate a datagrid by binding to the dataset. That works fine. The form has a button which, when clicked,...
0
by: Southcoaster | last post by:
I am relatively new to Visual Basic 2005 Express Edition. I am trying to create a simple program that: 1. Creates and populates a dataset in the form_load handler 2. Transfers control to a new...
2
by: markliam | last post by:
I have auto-generated some code for a button by double clicking it. By default, the code is created with a return type of void and assigned to a click event. Now, I want the function to return a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.