Gridview rowupdating method

23 Apr

Now you can ask questions directly to me on my new site ASPForums.

gridview rowupdating method-34gridview rowupdating method-34gridview rowupdating method-5gridview rowupdating method-39

Grid View Edit Event Args object knows the current row index so getting row index of the selected row in gridveiw is not big deal; just e. Value); Find the controls in the selected row by using Find Control method of gridviews rows collection and collect data from the text boxes. Check for Comman Name and invoke delete method for the selected row.

Set the Data Key Names property of Grid View to Primary Key Column of Data Base i.e. This property binds the database column field value to each row of gridview as a Unique Identifier.

Set the data bindings for Delete Button for Command Argument Eval(“Emp Id”); for saving the ID column value from database for fetching the ID field value while Deleting the Record.

Instead if you are using default Delete Button of Grid View then register for Row Deleting event of Grid View and for accessing Unique ID columnvalue from database you need to fetch the id from Data Keys collection of Grid View. By default Edit Index of gridview is -1 (Normal mode). Find Control(“txt Designation”) as Text Box; Finally update the row and refresh the grid.

If you want to edit 3rd Row then set the Edit Index to 2 (Row index starts from 0,1,2..). Find Control(“txt Emp Name”) as Text Box; Text Box txtdesign = dg Employees. Custom Delete in Grid View For Delete register Row Command event of the gridview.