hi im new to programing and im trying to make a program that would calculate the tax on a given price but that would accept the tax rate as either an integer or a double but i get this error Index (zero based) must be greater than or equal to zero and less than the size of the argument list

my code looks like this

 private string DisplayMenu()
        {
            //Get Data from Database
            string sConnectionString = ConfigurationManager.ConnectionStrings["SiteSqlServer"].ConnectionString;
            SqlConnection objCon = new SqlConnection(sConnectionString);
            string strSql ="SELECT  CateID,CateName,PaID  FROM Dynamic ";
            SqlCommand objCommand = new SqlCommand(strSql, objCon);
            objCon.Open();
            SqlDataReader dataReader = objCommand.ExecuteReader();

            dtPage.Load(dataReader);
            objCon.Close();

            //Display root menu (with parentid=0)
            sbMenu.Append("<ul class=\"sf-menu\">");
            for (int i = 0; i < dtPage.Rows.Count; i++)
            {
                if (dtPage.Rows[i]["paID"].ToString() == "0")
                {
                    sbMenu.AppendFormat("<li> <a href=\"{0}\">{1}</a>", dtPage.Rows[i]["CateName"]);
                    RecursiveMenu((Int32)dtPage.Rows[i]["CateID"]);
                }
            }

            sbMenu.Append("</ul>");

            return sbMenu.ToString();
        }

        private void RecursiveMenu(Int32 paID)
        {
            List<DataRow> lstChilds = new List<DataRow>();
            for (Int32 i = 0; i < dtPage.Rows.Count; i++)
            {
                if ((Int32)dtPage.Rows[i]["paID"] == paID)
                {
                    lstChilds.Add(dtPage.Rows[i]);
                }
            }

            if (lstChilds.Count() > 0)
            {
                sbMenu.Append("<ul>");
                foreach (var row in lstChilds)
                {
                    sbMenu.AppendFormat("<li><a href=\"{0}\">{1}</a>", row["CateName"]);
                    RecursiveMenu((Int32)row["CateID"]);
                }
                sbMenu.Append("</ul>");
            }
            else
            {
                sbMenu.Append("</li>");
            }
        }

Recommended Answers

All 2 Replies

Could you specify the line where the error occured?

thanks for reply.
But i can't see the line where the error occured. i see it in my web. i use dotnetnuke and i see the error when i create module.
plz help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.