0

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 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?

1 Answer 1

1

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;
}
Sign up to request clarification or add additional context in comments.

1 Comment

Wao...Thanks this could help me lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.