Comparison of cells in a DataGrid

Source: Internet
Author: User
datagrid| Comparison | Cell comparison in cell "sharing" datagrid

It took nearly half an hour to test it out.
The row representation of the DataGrid in the ASP.net is also DataRow.
I can't find it anyway.
Then I saw a datagriditemcollection and DataGridItem.
The latter hint is the item (row) of the DataGrid.

So I used this sentence:

int i = DgCourse.Items.Count; Dgcourse as DataGrid instance

Returns the value of I for the specific number of rows, so, finally, I found the line.
But what if the columns in the row are compared?
And I think of DataColumn.
There's a datagrid.columns in the DataGrid.
But that's only for all columns, not for a single row of column comparisons.
So he looked in the Datagrid.item,
Found that there is a DataGrid.Item.Cells, the hint said "DataGrid Item Cell"
Well, it's supposed to be it, take two index and convert string to int to compare see


int coursecount = 0;
int coursepeo = 0;
foreach (DataGridItem di in dgcourse.items)//DataGridItem represents rows in the DataGrid
{
coursecount = Int. Parse (di. CELLS[5]. Text); Datagriditem.cells[5] represents the 6th cell in a row
COURSEPEO = Int. Parse (di. CELLS[6]. Text);
if (coursecount <= coursepeo)//cell for comparison
{
Di. CELLS[6]. ForeColor = system.drawing.color.red;//if not greater than show red
}
}


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.