Click here to Skip to main content
15,920,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a datatable which may contain one row or more than one rows. I want to implement some functionality one each retrived row. For example if dt.Rows[0] != null then i want to populate some controls. But When my datatable returns 1 row and I check whether it has second row apart from first row like this if dt.Rows[1] != null. It throws error " there is not row at this position" plz guide.
Posted

Why dont you just check the count? Something like (dt.Rows.Count > 1).
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 2-Feb-11 4:46am    
5, just for fun!
--SA
O yes..
thaks a loooooooooooooooooot
 
Share this answer
 
Comments
Manas Bhardwaj 2-Feb-11 4:37am    
voted down because you added it as an answer. You should always add comment back to original post.
Abhinav S 2-Feb-11 4:41am    
You are welcome. Next time post your comment as a comment though. 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