0
我的GridView與AutoGenerateDeleteButton =真 & & AutoGenerateEditButton屬性=真。 我想只允許註冊用戶使用這些功能,因此我想隱藏未註冊的用戶。我怎樣才能隱藏它?ASP.net的GridView:隱藏編輯|刪除鏈接
我試圖隱藏整個列,但在page_load gridView尚未準備好,所以我得到空異常。
我的GridView與AutoGenerateDeleteButton =真 & & AutoGenerateEditButton屬性=真。 我想只允許註冊用戶使用這些功能,因此我想隱藏未註冊的用戶。我怎樣才能隱藏它?ASP.net的GridView:隱藏編輯|刪除鏈接
我試圖隱藏整個列,但在page_load gridView尚未準備好,所以我得到空異常。
在內部會議
protected void Page_Load(object sender, EventArgs e)
{
Session["usrRole"] = "1";
}
你的頁面加載事件存儲用戶角色在你的GridView檢查了會議&如果不等於你的管理員角色行數據綁定的情況下,你的刪除按鈕欄的顯示設置更改爲假
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (Session["usrRole"] != "1")
{
e.Row.Cells[0].Visible = false; //0 is autogenerate edit column index
e.Row.Cells[1].Visible = false; // 1 is autogenerate delete column index
}
}
}