ASP. NET parameters of the data source control

Source: Internet
Author: User

Many data source controls are supportedASP. NET parameters.

UseASP. NET ParametersYou can change the Command executed when the data source control is executed.

Different data source controls use different ASP. NET Parameters. For example, for sqldatasource, the parameter is the ADO. net parameter (that is, the parameter using the slq Statement ). For the objectdatasource control, the parameter is a method parameter, which is a parameter of the Business Object method.

 

Sqldatasource, accessdatasource, and objectdatasource all support the following types of parameter objects:

    • Parameter object -- arbitraryStatic Value
    • Contrlparameter object --Control ValueOrPage property value
    • Cookieparameter object --Cookie value of the browser
    • Formparameter object --Field Value in HTML form
    • Querystringparameter object --Value of the field in "query string"
    • Sessionparameter object -- (stored in)Value of the item in the session

Example

 

<% @ Page Language = " VB  " %>

<! Doctype html Public " -// W3C // dtd xhtml 1.0 transitional // en " " Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd " >

<SCRIPT runat = " Server " >

Protected Sub Ddlcategory_selectedindexchanged ( Byval Sender As Object , Byval E As System. eventargs)

End sub
</SCRIPT>

<HTML xmlns = " Http://www.w3.org/1999/xhtml " >
<Head runat =" Server " >
<Title> </title>
</Head>
<Body>
<Form ID = " Form1 " Runat = " Server " >


<Div>
<Asp: dropdownlist id = " Ddlcategory " Performanceid = " Sdscategory " Runat = " Server "
Datatextfield = " Name " Datavaluefield = " ID " Onselectedindexchanged = " Ddlcategory_selectedindexchanged " />

<Asp: button id = " Btnselect " TEXT = " Submit " Runat = " Server " />
<Asp: gridview id = " Gv1 " Runat = " Server " Performanceid = " Sdsmovies " />
</Div>

<Asp: sqldatasource id = " Sdscategory " Runat = " Server "
Connectionstring = " Data Source =. \ sqlexpress; Integrated Security = true; user instance = true; attachdbfilename = | datadirectory | mydatabase. MDF "
Selectcommand = " Select ID, name from moviecategories " />

<Asp: sqldatasource id = " Sdsmovies " Runat = " Server "
Connectionstring =" Data Source =. \ sqlexpress; Integrated Security = true; user instance = true; attachdbfilename = | datadirectory | mydatabase. MDF "
Selectcommand = " Select title, Director from movies where categoryid = @ ID " >
<Selectparameters>
<Asp: controlparameter name = " ID "
Type = " Int32 "
Controlid = " Ddlcategory " />
</Selectparameters>
</ASP: sqldatasource>

</Form>
</Body>
</Html>


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.