Hello,
I have a textbox inside template field of a gridview. On button click I'm trying to sum all the textboxex where are not null. Below is my code.
foreach(GridViewRow grv in grvSalesTypes.Rows)
{
TextBox grvSalesAmount=(TextBox)(grv.Cells[1].FindControl("txtSalesAmount"));
if(!string.IsNullOrWhiteSpace(grvSalesAmount.ToString()))
{
AmountFromSales +=decimal.Parse(grvSalesAmount.Text);
}
}
I need to skip if the textbox is empty. I have used (!String.IsNullorWhiteSpace) but still it goes into the for loop even for null values.