在已登录用户群上的Gridview中编辑记录. [英] Editing records in Gridview on logged-in user base.

查看:67
本文介绍了在已登录用户群上的Gridview中编辑记录.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在gridview中显示记录.

现在,条件是登录的用户可以看到所有信息,但只能删除自己的记录.

我没有掌握主要逻辑!

希望有人能帮忙!

谢谢

Hi,

I want to display records in a gridview.

Now, the condition is that the logged in user can see all the information but can only delete his own records.

I am not getting the main logic!

Hope someone could help!

Thanks

推荐答案

我认为在gridview中,您将拥有可以与登录用户会话匹配的任何字段,例如用户名或ID.要禁用其他人的删除权限,您可以按以下方式在gridview中隐藏其他行的删除按钮

I think in gridview you would have any field like username or ID that you can match with the session of logged in user. To disable the delete right for other you can hide delete button of other rows in your gridview in following way

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
    if (e.Row.RowType == DataControlRowType.DataRow)
     {
        if (!DataBinder.Eval(e.Row.DataItem, "Column_Of_UserName").Equals(Session["User"].ToString()))
          {
              LinkButton btn = (LinkButton)e.Row.Cells[Indext of your commandfield column].Controls[0];
              if (btn != null)
               {
                    btn.Visible = false;
               }
          }
    }
}


这篇关于在已登录用户群上的Gridview中编辑记录.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆