I've been working with ASP.NET WebForms for a while and I've decided to try to convert some of my work into ASP.NET MVC.
Now, I can't figure out why my DataRow
is null
when there are results/rows.
Here is the code and error
string id= Session["role"].ToString() == "Admin" ? "0" : Session["emp_id"].ToString();
DataTable dt2 = getdata.accessAdmin(id);
DataRow[] dr = dt2.Select("default=0");
if (id != "0" && Session["emp_id"].ToString() != "0")
{
<li>
<a href="employee-dashboard"><i class="fa fa-arrow-left"></i><span>Back </span></a>
</li>
}
foreach (DataRow row in dr)
{
if (row["url"].ToString().Length > 1)
{
<li>
<a href="@row["url"]">
<i class="@row["icon"]"></i><span>
@row["name"]
</span>
</a>
</li>
}
}
my getdata.cs :
public static DataTable accessAdmin(string id)
{
return dbhelper.getdata("Select a.user_id,b.* from nobel_userRight a left join nobel_route b on b.id=a.route_Id where b.system=2 and a.user_id=" + id + " order by seqs asc");
}