TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Valerie Meunier
NA
693
82.9k
problem with empty field in gridview when updating
Apr 15 2021 4:48 PM
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
Reply
Answers (
5
)
reading Json and Xml
asp.net core filtering not working properly