I want to populate the gridview in asp.net web application.
in fact I am able to do it but my scenario is I want to develop it based on user authentication. means Let say Admin is logged in then he must authorized to edit all fields of row in gridview. but say if Employee is logged in then, he should only applicable for to edit Name and Address columns in gridview. can i do开发者_如何学JAVA this ? what I have to take under consideration.
in which event i can do this?
Also how can i convert / create this gridview as user control?
let us say you have column of Edit Command like...
<asp:TemplateField>
<ItemTemplate>
<asp:ImageButton ID="ibtnEdit" CommandArgument='<%# Eval("id") %>' CommandName="Edit" runat="server" />
</ItemTemplate>
</asp:TemplateField>
and now you have to hide edit column, so that user will not be able to edit records. you need to put condition like...
if(User not in in Admin role)
{
GridView1.Column[EditColumnIndex].Visible = False;
}
精彩评论