In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how C#binds related data, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
Flexible use of C#binding data operations
Binding to simple properties:
Bind to collection:
Binding to expressions:
Bind to method return value:
Bind to Hashtable:
Bind to ArrayList:
If the array contains an object, it may need to perform the necessary conversion before binding, such as:
Binding to DataView,DataTable,DataSet:
or
To format:
Binding to DataReader:
Of course, for convenience, the most commonly used is the DataBinder class Eval method. However, this is less efficient for binding a large amount of data at the same time
This sentence is often used when binding data: or
Today, I learned another one, and Microsoft also said that this method is more efficient than the above two.
Very useful, so you can do a lot of things on the front page.
Also remember that you must import the namespace System.Data in the foreground page to do this, otherwise an error message will be generated.
This usage is actually the same as the reason.
When binding to DataSet or DataTable:
C#When binding to DataReader:
The key is Container, which is more mysterious. Its namespace is System.ComponentModel. I need to understand it further.
Beginner. NET, now looking at DataGrid controls, when displaying data in ItemTemplate,
What is the difference between DataBinder.Eval(Container.DataItem,"Name") and Container.DataItem("Name")?
DataBinder is a static class in System.Web, which provides Eval method to simplify the writing of data binding expressions, but it uses a method such as Reflection to achieve ease of use, so its performance is not ***. Container is not any static object or method at all, it is a local variable declared by ASP.NET page compiler inside the data binding event handler, its type is the data container type of the control that can be data bound (such as the data binding container inside Repeater is called RepeaterItem), basically there is DataItem attribute in these container classes, so you can write Container.DataItem, this attribute returns the data item in the data source you are bound to. If your data source is DataTable, then the type of the data item is actually DataRowView.
Thank you for reading this article carefully. I hope that the article "How to bind related data to C#" shared by Xiaobian will be helpful to everyone. At the same time, I hope that everyone will support you more and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.