Get controls in Footer in DataGrid

zhaozj2021-02-16  103

Today, I have organized a FOOTER's article. In many cases, because you need to put some controls in Footer, you will never encounter a small trouble when you get these controls, because Footer, Header, Pager is not in the DataGrid.Items property, the property returns a collection Only Items generated by data binding, so you must do it with other methods. Below is a few ways to summarize from 9CBS and elsewhere: 1. In iTeamCreated or itemDatabase, the specific code is not written. 2. Traverse all Items of DataGrid. DataGrid.Controls [0] Generally, it is generated Table. The code is as follows: Foreach (DataGridItem Item IN DataGrid.controls [0] .controls) {if (item.type == ListiteMTYPE.FOOTER) // Find the corresponding control with item.FindControl}} All two methods are often used, Here, there are two other ways proposed by the previous 9CBS. 3.Table T = (Table) DataGrid.controls [0]; // If you have Pager, then you need to encode T.Rows [T.Rows.count-2] to get PagerDataGridItem Item = (DataGridItem) T. Rows [T.ROWS.COUNT-1]; // This item is Footer, you can find it with FINDControl. 4. If there is only one footer, you can use the average HTML tag in Footer, then you can use Request.form ['YourControlName'] to get it; but this is not easy to do it. The server changes its value.

转载请注明原文地址:https://www.9cbs.com/read-13375.html

New Post(0)