'how to find out textbox value is greater than datagridview cell value in c#
i have a numeric value in textbox which is retrieve from sql database, meanwhile i have unbound GridView with some rows. now i want to compare the textbox value to datagridview cell value.. please help me
Solution 1:[1]
if(int.Parse(textBox.Text) > dataGridView.Rows[0].Cells[0].Value)
{
// Here you do what you want to do
// when the textbox value is greater than the grid cell value.
}
This code will check against the first cell of the first row. If you want to check against another cell, you should change the row index from Rows[0]
to Rows[/* row index */]
, and the column index from Cells[0]
to Cells[/* cell index /*]
.
Note: Your question was downvoted because you didn't show us what have you tried. Read this article to learn how to ask good questions: How do I ask a good question?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |