In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
How to encode and determine the corresponding value of the data in the event handling of RowDataBound? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
When ProductsDataTable is bound to GridView,GridView, several ProductsRow will be generated. The DataItem property of GridViewRow will generate an actual ProductRow. In order to determine the value of UnitsInStock after the RowDataBound event of GridView, we need to create the event handler of RowDataBound, in which we can determine the value of UnitsInStock and format it accordingly
The creation process of EventHandler is the same as the previous two.
RowDataBound: event handling for creating the RowDataBound event of a GridView
The following code will be automatically generated in the background code
Protected void HighlightCheapProducts_RowDataBound (object sender, GridViewRowEventArgs e) {}
When the RowDataBound event is triggered, the second parameter, GridViewRowEventArgs, contains a reference to GridViewRow. We use the following code to access the ProductsRow in GridViewRow
Protected void HighlightCheapProducts_RowDataBound (object sender, GridViewRowEventArgs e) {/ / Get the ProductsRow object from the DataItem property... Northwind.ProductsRow product = (Northwind.ProductsRow) ((System.Data.DataRowView) e.Row.DataItem) .Row; if (! product.IsUnitPriceNull () & & product.UnitPrice < 10m) {/ / TODO: Highlight the row yellow... }}
When using RowDataBound event handling, GridView consists of various types of rows, and for all row types, the type of GridViewRow can be determined by the RowType property, which can be one of the following types
A record in the DataSource of DataRow-GridView
An empty behavior shown by the DataSource of EmptyDataRow-GridView
Footer-bottom line; display is determined by the ShowFooter property of GridView
Header-header line; display is determined by the ShowHeader property of GridView
Pager-GridView pagination, this line shows the markup of the paging
Separator-not available for GridView, but useful for the RowType properties of DataList and Reapter, which we will discuss in future articles
When the above four (DataRow, Pager Rows Footer, Header) are not suitable for the corresponding values, an empty data item will be returned, so we need to check the RowType property of GridViewRow in the code to determine:
Protected void HighlightCheapProducts_RowDataBound (object sender, GridViewRowEventArgs e) {/ / Make sure we are working with a DataRow if (e.Row.RowType = = DataControlRowType.DataRow) {/ / Get the ProductsRow object from the DataItem property... Northwind.ProductsRow product = (Northwind.ProductsRow) ((System.Data.DataRowView) e.Row.DataItem) .Row; if (! product.IsUnitPriceNull () & & product.UnitPrice < 10m) {/ / TODO: Highlight row yellow... } the answer to the question on how to encode and determine the corresponding value of the data in the event handling of RowDataBound is shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.
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.