Click here to Skip to main content
14,301,895 members
Rate this:
Please Sign up or sign in to vote.
See more:
I am trying to bind the dataset to tree view control in following way but system raising the following error.


TreeNode no = new TreeNode();
DataSet ds = new DataSet();
ds = objTreebl.BindClass();
for (int i = 0; i<= ds.Tables[0].Rows.Count; i++)
{
no.Text =ds.Tables[0].Rows[i]["Class"].ToString();
no.Value = ds.Tables[0].Rows[i]["Class"].ToString();

this.Tree.Nodes.Add(no);


Error message:Index must be within the bounds of the List.
Parameter name: index
Posted

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Replace

i<= ds.Tables[0].Rows.Count


with

i < ds.Tables[0].Rows.Count



If your problem is solved, you may accept and vote the solution. Otherwise please post your queries

PES
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100