Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
17
Reply
Preventing repeated data into the gridview
Vishnu Suresh
Oct 5 2015 4:05 AM
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.
Upload Source Code
Select only zip and rar file.
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#