I have a DataGridView
and added a column called SellQty
and a Checkbox
at index 0. User has to enter int
value when he selects a checkbox
. If not I am showing a message to enter the value. Now the problem is I am getting the value from the SellQty
cell and storing it in an object
and checking whether it is null
.
object SellQty = gvProductBatch.Rows[i].Cells["txtSellQty"].Value;
if(SellQty!=null)
// do something
else
// ..Show message.
This works fine. But the problem is when the user enters a value and deletes it, the value stored in it is {}
ie empty. I would like to know how to check an object is empty. I have googled for the same but didn't find answer to handle empty object. All results were for if object is null.
You can get the actual edited Value by using the .EditedFormattedValue
if (string.IsNullOrWhiteSpace(gvProductBatch.Rows[i].Cells["txtSellQty"].EditedFormattedValue.ToString())
{
//Do something
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.