What types of objects does DataGrid. datasource receive? Accept

Source: Internet
Author: User

Use the setdatabinding method to set the datasource and datamember attributes at runtime.

The following data sources are valid:

L datatable

L dataview

L Dataset

L dataviewmanager

L any component that implements the ilistsource Interface

L any component that implements the ilist Interface

 

If datasource references more than one table, you must set a string to the datamember attribute, which specifies the table to bind. For example, if datasource is a dataset or dataviewmanager that contains three tables: MERs, orders, and orderdetails, you must specify the table to bind.

Setting datasource to an object that does not implement the ilist interface or an ilistsource will cause grid exceptions.

By using dataview as a data source and setting the addnew attribute to false, you can create a grid that allows users to edit data but prevent them from adding new rows.

To bind a DataGrid to a strong array of objects, the object must contain public attributes. To create a datagridtablestyle that displays such arrays, set the mappingname attribute to classname [], where classname will be replaced by the class name. Note that the mappingname attribute must be case sensitive.

You can also bind the DataGrid to the arraylist. One feature of arraylist is that it can contain multiple types of objects, but when all items in the list have the same type as the first item, the DataGrid can only be bound to this type of list. This means that all objects must be of the same type, or must be inherited from the first class in the list. For example, if the first item in the list is control, the second item may be Textbox (which inherits from control ). On the other hand, if the first item is Textbox, the second object cannot be control. In addition, arraylist must contain items when binding. Empty arraylist results in empty mesh. When binding to arraylist, set datagriingname of the datagridtablestyle to "arraylist" (type name ).

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.