Click here to Skip to main content
15,891,529 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to check the values in grid row one by one.How can i do that?
My grid contains one row and am adding rows using dr.add row but i need to check the each values in row for validation(Avoiding duplicate values)

How can i avoid duplicate values?
please share your logic and knowledge
Posted
Updated 4-Mar-13 22:55pm
v5
Comments
Am Gayathri 5-Mar-13 3:45am    
please help
willington.d 5-Mar-13 4:00am    
so u r adding rows dynamically when you click add button and validating that the entered value is already existing in the grid right?

1 solution

C#
foreach (GridViewRow gr in yourGrid.Rows)
            {
//Your validation code in add Button
}
 
Share this answer
 
Comments
Am Gayathri 5-Mar-13 4:17am    
How can i get the value of a particular row? also how to get the items count?
willington.d 5-Mar-13 4:32am    
Hi Kavithale

if you are using template field in the gridview:
foreach (GridViewRow gr in yourGrid.Rows)
{
string strValue = ((Label)gr.FindControl("controlname")).Text
}

or

for (int i = 0; i < dataGridView1.Rows.Count; i++)
{
DataGridViewRow row = dataGridView1.Rows[i];
row.Cells[2].Value = true;
}
willington.d 5-Mar-13 5:37am    
Is it working?
Am Gayathri 5-Mar-13 4:49am    
DataGridViewRow IS THIS MY GRIDVIEWNAME?
Orcun Iyigun 5-Mar-13 5:04am    
yourGrid!!!! is the ID of your gridview...(in the for each loop)
dataGridView1 is the ID of your gridview...(in the for loop)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900