Hi
When editing a row of a gridview, some fields can remain empty.
But with this code, i get the error (if field 'name" remained empty) when updating: "Object reference not set to an instance of an object.":
protected void GridView1_RowUpdating(object sender, System.Web.UI.WebControls.GridViewUpdateEventArgs e)
string name;
name = e.NewValues["name"].ToString();
I tried to prevent that with this code:
if (string.IsNullOrEmpty(e.NewValues["name"].ToString()) == true)
name = e.NewValues["name"].ToString();
else
name ="";
But I get the same error (at line if ...)
Thanks for help.
V
5 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Salman BegPosted Apr 15, 2021, 5:34 PM
Valerie MeunierPosted Apr 16, 2021, 8:18 AM
Valerie MeunierPosted Apr 15, 2021, 9:49 PM
Valerie MeunierPosted Apr 15, 2021, 9:23 PM
Sachin SinghPosted Apr 15, 2021, 5:36 PM