0

I'm trying to check null or empty value in mvc view side in shortest way in one go but not able to achieve null.

i have value coming from controller in array and in view side i'm checking null or empty

controller

object o3 = ds.Tables[6].Rows[0]["pm"];
                if (o3 != null)
                {
                    string val = o3.ToString();
                    string[] values3 = val.Split('~');
                    ViewBag.values3 = values3;
                }

View side

<td>@(values3[0].IsEmpty()?0:Convert.ToInt32(values3[0]))</td>

Expected:Both null and empty value should be cheked in one go and 0 should be output if value is null or emty. Actual:Able to check only empty value. Any idea how to check both null and empty value in shortest way would be appreciated.

Mohan
  • 238
  • 2
  • 15

0 Answers0