仅向预订员工提供编辑选项 [英] Giving edit option only to booking employee

查看:46
本文介绍了仅向预订员工提供编辑选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个gridview,它显示表中存在的所有数据.在该gridview中,我保留了编辑"和取消"按钮,因此我的要求是预订房间的员工应该可以使用编辑"和取消"按钮,而对于其他员工,该条目应该是只读的,即他们不能编辑该条目. br/>
谁能帮我.

提前谢谢!

Hi,
I am having one gridview and it''s displaying all the data present in table. In that gridview I kept the edit and cancel buttons so my requirement is that edit and cancel button should be available to the employee who booked the room and for other employees the entry should be readonly i.e they should not be able to edit that entry.

Can any one please help me.

Thanks in advance!

private void Validate()
    {
        for (int count = 0; count < gvconference.Rows.Count; count++)
        {
            if (Session["EmployeeId"] == gvconference.Rows[count].Cells[0])
            {
                gvconference.Rows[count].Cells[0].Enabled = false;
            }
            else
                gvconference.Rows[count].Cells[0].Enabled = true;

        }
    }


请检查我发布的代码以告诉其中的任何更改.


please check the code i posted tell any changes in that.

推荐答案

您将想在GridView.RowDataBound事件上研究示例:http://msdn.microsoft.com/en-us/library/system.web .ui.webcontrols.gridview.rowdatabound.aspx [ ^ ].

数据提供时,每一行都会触发它.您希望在数据中有一列显示预订房间的用户(如果您不想显示该列,则该列可以隐藏在gridview中).如果当前登录的用户与数据中的用户相同,则将启用编辑和取消按钮.对于所有其他用户,这些按钮要么完全不显示,要么可以被禁用.

希望对您有帮助!
You''ll want to study the example on the GridView.RowDataBound event: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx[^].

It is fired by each row as it is supplied with data. You''d want to have a column in your data that shows which user booked the room (column can be hidden in gridview if you don''t want to display it). If the currently logged on user is the same one as the one in your data you''ll enable the edit and the cancel button. For all other users the buttons will either not be displayed at all or they can just be disabled.

Hope that helps you!


我一直在标记绑定中使用这种情况
I always use to handle such situation in markup binding
 <asp:templatefield xmlns:asp="#unknown">
    <itemtemplate>
        <asp:linkbutton id="lblCreateSale" runat="server" commandname="Edit" visible="<%#Eval("BookingUserID").ToString()==CurrentUser %>" text="Edit" />
    </itemtemplate>
</asp:templatefield>


在Codebehind
创建属性CurrentUser


create a property CurrentUser at Codebehind

public string CurrentUser
{
   get
   { 
      //write code to return current user id
   }
}



--Pankaj



--Pankaj


这篇关于仅向预订员工提供编辑选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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