ASP.NET gridview onrowediting

zintech
zintech used Ask the Experts™
on
I have a GridView that I fill with a SQL statement when a Button is clicked that works fine.  My question is, I have an Edit button on each row of the GridView, and I don't know what code to write to have the user be able to edit each individual row when the GridView1_OnRowEditing() event fires.  I haven't been able to find an example of how I would do this.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Could you clarify your question?  

Generally, adding a command field for edit,update,cancel will enable the user to select which row to place in edit mode.  Only if you need to do some special processing would you need to code the OnRowEditing event (hence the lack of examples).  BoundFields, CheckBoxFields, and template fields(edit templates) allow data input.

Author

Commented:
One thing I must note is that I am only showing the Edit option on the Gridview for certain users.  so I am limiting user access to Edit/Update and I use the GridView1.AutoGenerateEditButton = true statement for those users.  Does this change how I would go about Editing?
The AutoGenerateEditButton property is equilevent to the adding the command field.  
However, with you wanting to control authorization to edit/update. There are couple of ways to do this depending upon your security architexture if it applies to the whole gridview or per row.

In your code behind set the AutoGenerateEditButton property depending on the user's authorization.  

If your using security on individual rows, then I would use the command field with the AutoGenerateEditButton = false. Then in the row binding, find the edit control and either hide or disable it for each datarow type (exclude header and footer).

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial