ASP. net2.0 sqldatasource get stored procedure return parameters

Source: Internet
Author: User

Recently, many friends who are new to the sqldatasource control are attracted to its powerful functions and easy-to-use features.

However, while improving the ease of use, sqldatasource will inevitably lose some flexibility. Many friends are worried that the sqldatasource control parameters cannot use sqlparameter.

The parameter used by the sqldatasource control is parameter. This class function is much simpler than the sqlparameter class. There are only a few simple attributes, and we can only use parameter. defaultvalue is a string type attribute setting parameter, which is inconvenient.

In a project, a colleague wants to use sqldatasource to call SQL
Server Stored Procedures, and accept the output parameters of stored procedures. In the initial stage, it uses sqldatasource. selectparameter
["Mypara"]. The defaultvalue method tries to obtain data, but all of them fail. No suitable answer is found for searching online. after repeated attempts, the result is finally successful.
In the onselected event of the sqldatasource control, you can call the sqldatasourcestatuseventargs parameter to obtain the output parameter of the stored procedure,CodeAs follows:

Protected void sqldatasourceincluselected (Object sender, sqldatasourcestatuseventargs E)
{
Label1.text = E. Command. Parameters ["mypara"]. value. tostring ();
}

It is helpful for friends who need to call the response parameters using datasource!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.