how can public function is convert to session
private void GetMenuData()
{
try
{
string meanu_id = "", a = "";
SqlParameter[] paramater1 = new SqlParameter[]
{
new SqlParameter("@Branch",1),
new SqlParameter("@Users",1),
};
SqlDataReader dr = (SqlDataReader)db.ExecuteReader("GetRoll_ForMeanu", paramater1);
if (dr.HasRows)
{
dr.Read();
meanu_id = dr["Menu_Id"].ToString();
a = dr["Role"].ToString();
}
dr.Close();
DataTable dt = new DataTable();
// dt = (DataTable)db.TableFill1("MenuMaster_SelectQuery");
dt = (DataTable)db.Meanu_Fill("SELECT menu_id, menu_name, menu_parent_id, menu_url, Target FROM MenuMaster where menu_id in(" + meanu_id + ") Order By menu_id");
DataView view = new DataView(dt);
view.RowFilter = "menu_parent_id is NULL";
foreach (DataRowView row in view)
{
MenuItem menuItem = new MenuItem(row["menu_name"].ToString(), row["menu_id"].ToString());
menuItem.NavigateUrl = row["menu_url"].ToString();
Menu1.Items.Add(menuItem);
AddChildItems(dt, menuItem);
//Session["menu"] = menuItem;
}
}
catch (Exception ex)
{
db.MessageBox(ex.Message, this);
}
}
private void AddChildItems(DataTable table, MenuItem menuItem)
{
DataView viewItem = new DataView(table);
viewItem.RowFilter = "menu_parent_id=" + menuItem.Value;
foreach (DataRowView childView in viewItem)
{
MenuItem childItem = new MenuItem(childView["menu_name"].ToString(), childView["menu_id"].ToString());
childItem.NavigateUrl = childView["menu_url"].ToString();
childItem.Target = childView["Target"].ToString();
menuItem.ChildItems.Add(childItem);
AddChildItems(table, childItem);
}
}
sir this is my function how to convert
Session["GetMenuData"]= GetMenuData();