This code is a bit complex but just add it knowing that we may refer to it in the future.
Here in Grid View, in the beginning the major part is to make the decision of putting either a bound field or a template field and the answer is simple: When we want to place any control inside the Grid View then we can go for template field, otherwise bound field will be simpler.
As a beginner it's very tough and challenging to work with controls like a Grid View in ASP. Even I faced difficulties at the starting point of my career. Here, I am not going to explain about Grid View and other events in it, because there are a lot of good articles about that.I am only going to show the different ways we can use code to take the value from Grid View.It then examines how to apply role-based URL authorization rules. When using forms authentication, an authentication ticket is used as an identity token.Following that, we will look at using declarative and programmatic means for altering the data displayed and the functionality offered by an ASP. As we discussed in the method will be called on every request to a page that is protected by the role-based URL authorization rules.To cancel the selection operation, set the property of the Grid View Sort Event Args object to true.
For information about how to programmatically initiate a sort operation, see the Sort method.This enables you to provide an event-handling method that performs a custom routine, such as canceling the sorting operation, whenever this event occurs.A Grid View Sort Event Args object is passed to the event-handling method, which enables you to determine the sort expression for the column and to indicate that the selection operation should be canceled.First, we have to very be clear in our mind that there are mainly two ways of taking the cell value from the Grid View: This code is for taking the value apart from the Grid View events; that is, any common event using a sender object.But ensure that the control/link is inside the Grid View, only then can we cast sender as Grid View.A more maintainable approach is to use role-based authorization.