Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Can Anyone ans:


instead of
C#
foreach (GridViewRow row in GridView1.Rows)



this code can we use any other code.
Posted
Comments
Nandhu_nands 25-Jun-19 9:39am    
why should you use this ?
can you please explain!

You can use any type of loop like above as required.
C#
int i = 0;
do
{
//Your code goes here.
i++;
}while(i < gridview1.rows.count);


-MKB
 
Share this answer
 
Comments
Wonde Tadesse 3-Dec-11 21:54pm    
5+
I've been wondering why you need another code since that iterating for GridViewRow is better in a foreach statement. But if you just want to know, then try Solution 1 or Solution 2. Or try this as well.

C#
int i = 0;
while(i < GridView1.Rows.Count)
{
//Your code here, use i as index throughout iteration
i++;
}


Best regards,
Eduard
 
Share this answer
 
Comments
Wonde Tadesse 3-Dec-11 21:54pm    
5+
[no name] 4-Dec-11 20:28pm    
thanks
You can iterate with a for loop:
C#
for (int i=0;i<gridview1.Rows.Count;i++){
   GridViewRow row = GridView1.Rows[i];
   // the rest o your code
}
 
Share this answer
 
v2
Comments
M.Narmatha 3-Dec-11 0:46am    
is for loop correct...
Mehdi Gholam 3-Dec-11 5:08am    
Fixed it... the formatter mangled the output.
Wonde Tadesse 3-Dec-11 21:53pm    
5+
Mehdi Gholam 4-Dec-11 0:10am    
Thanks

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