"Asp. Net 2.0 secrets" (15th)

Source: Internet
Author: User

ObjectDataSource Control

Five main attributes: TypeNmae SelectMethod UpdateMethod InsertMethod DeleteMethod;

* This control can represent any object. If this object does not support IEnumerable, it will be automatically packaged into the new object for its support;

* Use DataReader whenever possible

public sqlDataReader GetMovies(){  Sqlconnection con =new  ...  ...  con.open();  return cmd.Executereader(CommandBehavior.CloseConnection);}
* WebConfigurationManager. ConnectionStrings ["Movies"]. ConnectionString: Access connection string;
* If a parameter is required in the method bound to this control, the matching is automatically determined through reflection;
* The DataObjectTypeName attribute of DataObjectSource is invalid in the select method, and the class must have a constructor with or without parameters;
* General event organization method: process the insert operation in the ing event, and process the insert error information in the ed event to block the error;
* You can process the constructor with parameters in the OnObjectCreating event.
MoivesByCategroy movies=new MoviesByCategory("Adventure");e.ObjectInstance=moives;
* The above event is not triggered when a static method is called;
* Create a custom ObjectDataSource control Page 519

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.