0

I have a code like this:

private void FillMenu()
{
    int i;

    string sql = "Select * from tblMenu where MenuGrup=1 order by SiraNo";

    DataTable dt = ExecSqlDT(sql);

    if (dt.Rows.Count == 0)

        return;

    for (i = 0; i <= dt.Rows.Count - 1; i++)
    {

        DevExpress.Web.ASPxNavBar.NavBarGroup xGrp = new DevExpress.Web.ASPxNavBar.NavBarGroup();
        xGrp.Text = dt.Rows[i]["MenuAd"].ToString();
        if (!dt.Rows[i]["HeaderResimUrl"].ToString().Equals(""))
            xGrp.HeaderImage.Url = dt.Rows[i]["HeaderResimUrl"].ToString();
        if (!dt.Rows[i]["ItemResimUrl"].ToString().Equals(""))
            xGrp.ItemImage.Url = dt.Rows[i]["ItemResimUrl"].ToString();
        if (!dt.Rows[i]["Genisletilmis"].ToString().Equals("1"))
        {
            xGrp.Expanded = false;
        }
        else
        {
            xGrp.Expanded = true;
        }
        ASPxNavBar1.Groups.Add(xGrp);
        FillMenuGroup(xGrp, (long)dt.Rows[i]["MenuID"]);

    }
}

When i run my project, it breaks at this point:

FillMenuGroup(xGrp, (long)dt.Rows[i]["MenuID"]);

"Specified cast is not valid"

What should i do?

4

1 回答 1

0

You can try this to see if it works:

 FillMenuGroup(xGrp, Convert.ToInt64(dt.Rows[i]["MenuID"]));
于 2013-07-24T11:26:36.670 回答