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
Vishnu Suresh
NA
34
12.7k
Preventing repeated data into the gridview
Oct 5 2015 4:05 AM
I have a .net program in which datas are to be inserted through gridview. If I am adding the same data twice then I need to show error message that data repeated. How can I do this. I have used one code but it shows error.
for (int i = 0; i < GridView1.Rows.Count; i++)
{
TextBox txtSlno = (TextBox)GridView1.Rows[i].Cells[1].FindControl("txtSlno");
if (txtSlno.Text != "" || txtSlno.Text != null)
{
if (txtSlno.Text == dt.Rows[i]["SlNo"].ToString())
{
Label1.Text = "already exist";
break;
}
else
{
Label1.Text = "";
}
}
}
It shows error there is no row at position zero.
Reply
Answers (
17
)
After inserting data into the gridview page reloading
how to avoid page reload in nested gridview asp.net c#