Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
17
Reply
Preventing repeated data into the gridview
Vishnu Suresh
8 years ago
2.3k
Reply
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.
Post
Reset
Cancel
Answers (
17
)
Next Recommended Forum
After inserting data into the gridview page reloading
how to avoid page reload in nested gridview asp.net c#