Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find a DataGridView cell

How do I find a cell with a specific content in a DataGridView?

like image 527
mafu Avatar asked Nov 21 '25 08:11

mafu


2 Answers

I dont know of a way to find a cell by content so you'll have to iterate through the cells and look for the value you need. You can use the .FindControl() method to find actual controls (label, literal, checkbox, etc) inside cells or go through them by index GridView.Rows.Cells[index]

Edit: This answer will work on an ASP.NET page (tested) and should work in a winform (untested)

like image 200
Ariel Avatar answered Nov 23 '25 22:11

Ariel


Ariel is right on, you will have to iterate through the GridViewRowCollection and then each cell of the individual GridViewRow, you can get the cell's text property or like Ariel mentioned if it is a control use FindControl and extract the appropriate property

like image 44
Ta01 Avatar answered Nov 23 '25 23:11

Ta01



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!