E. Item. DataItem format after conversion in the ItemDataBound event of Repeater

Source: Internet
Author: User

Today, I 'd like to review the data of the current row in the ItemDataBound event without the need to bind a Repeater Layer 3. item. dataItem can also be used to directly return an object with three layers of time. For example, the time code for using List as the data source is ZM. zhao. model. channelInfo info = (ZM. zhao. model. channelInfo) e. item. dataItem, which can call the data of this object through attributes. However, when dataset is used, the conversion fails. The reason is as follows: The Rpeater bound to different types of data sources does not obtain the same type at the end ------

1. When you bind a data source with DataSet and DataTable

DataRowView view = (DataRowView) e. Item. DataItem;

2. When DataReader is bound to a data source

System. Data. Common. DbDataRecord view = (System. Data. Common. DbDataRecord) e. Item. DataItem;

3. When Using Generics as the data source, it is the type corresponding to generics.

For example, IList <DocumentInfo> is the data source.
DocumentInfo docInfo = (DocumentInfo) e. Item. DataItem;

 

Only the time for using List as the data source can be operated as before.

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.