Click here to Skip to main content
15,894,740 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

Replace

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


with

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



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

PES
 
Share this answer
 

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