내 프로젝트에 격자보기가 있습니다. 프로젝트가 관리자로 로그인하면 편집하고 볼 수있는 권한이 있습니다. 하지만 내가 사용자로 로그인 할 때 편집 옵션을 비활성화하려고합니다. 템플릿 필드 내부의 링크 버튼 인 편집 옵션을 비활성화하려고하는데 오류가 발생합니다. 다음은 rowdatabound 이벤트 내에서 컨트롤을 가져 오지 못합니다.
내 코드는 지금까지 시도이다 이protected void gvDocuments_RowDataBound(object sender, GridViewRowEventArgs e)
{
string username = Convert.ToString(Session["Username"]);
LinkButton btn = (LinkButton)gvDocuments.FindControl("lbtnEdit");
if (username == "user")
{
btn.Visible = false;
}
}
누군가가 내가 잘못 갔다 좀 도와 줄래 ???
편집 됨 :는
<asp:GridView ID="gvDocuments" runat="server" AutoGenerateColumns="False" OnRowDataBound="gvDocuments_RowDataBound" OnRowCommand="gvDocuments_RowCommand" PageSize="5" Width="100%" RowStyle-BackColor="#9FCFFF" SortedAscendingHeaderStyle-VerticalAlign="Bottom" SortedAscendingHeaderStyle-HorizontalAlign="Left" BackColor="#9BCDFF" HeaderStyle-BackColor="#51A8FF">
<asp:TemplateField HeaderText="Actions">
<itemtemplate>
<asp:LinkButton ID="lbtnView" runat="server" CommandName="View" Text="View" ForeColor="#0033CC"></asp:LinkButton>
<asp:LinkButton ID="lbtnEdit" runat="server" CommandName="DocEdit" Text="Edit" ForeColor="#0033CC"></asp:LinkButton>
<asp:LinkButton ID="lbtnRenew" runat="server" CommandName="Email" Text="Email" ForeColor="#0033CC"></asp:LinkButton>
</itemtemplate>
</asp:TemplateField>
</asp:GridView>
그리드 용 html 코드를 도울 수 있다면 알아낼 수 있도록 –
무엇이 오류입니까? – tarzanbappa
나는 그 대답 – Maes