-1

hi there,

i have a code to display data from a database to a dataagrid view and while adding data i add rows also to the datagrid view but when the second time the code runs it gives an exception saying index tou of bound, how can i solve this.
i have attached the the doc with the error msg and the code. the dt.row.count = 2.

thanxxx

2
Contributors
1
Reply
3
Views
8 Years
Discussion Span
Last Post by farooqaaa
0

You have used "1" as the starting index in the for loop. You should use "0".

Try this:

for (int r = 0; r < dt.Rows.Count; r++)
{
   .....
}

Thanks

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.