Use objectdatasource to note the naming conventions of parameters in deletemethod, updatemethod, insert, and other methods.

Source: Internet
Author: User
Use objectdatasource to note the naming conventions of parameters in methods such as deletemethod and updatemethod:
For example, if the updatemethod prototype is:
<Dataobjectmethod (dataobjectmethodtype. Update, true)> _
Public shared sub updatebuild (byval sbuildid as string, byval sbuildno as string, byval sbuildloc as string)
The parameter value should be:
<Updateparameters>
<Asp: controlparameter controlid = "txtbuildid" name = "sbuildid" propertyname = "text"/>
<Asp: controlparameter controlid = "txtbuildno" name = "sbuildno" propertyname = "text"/>
<Asp: controlparameter controlid = "txtbuildloc" name = "sbuildloc" propertyname = "text"/>
</Updateparameters>
The parameter names in these parameters must be exactly the same as the method names in updatemethod.
The Datakeynames The property is assigned as the primary key of the implicit object. This is in use Gridview This attribute indicates the field (or a group of fields) that identifies a unique record ).
---------------- supplement several conventions of objectdatasource
when objectdatasource is bound to a gridview and columns are bound using the <% # expression, update the settings. Note:
1. set datakeynames of the gridview as the primary key value (to update the required primary key column)
2. in the update method of objectdatasource, the parameter name must be the same as the field name of the retrieved record
3. all data field names in the <% # Bind Column must appear in the parameters in the update method of objectdatasource
4. if you need to set the format name oldvaluesparameterformatstring = "org _ {0}" of the original key value based on the original primary key value, and set the format name according to the datakeynames (for example, ID) of the gridview) org_id, which is formed by field names in.
5. you do not need to set the updateparameters attribute. Unless there are additional parameters, conflictdetection does not need to be set (overwritechanges is used by default)
If 3 or 5 is not met, "The non-generic method XXXXX cannot be found" appears.

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.