It covers most of the basic reports for which you do not need any reporting component like Crystal Report, Report Viewer etc. Major concern with any data entry form is Add, Edit, Delete and View. Uncheck Auto-Generate Field from the Property window. This property binds the database column field value to each row of gridview as a Unique Identifier. The CommandName property can contain any string name which can be used to recognize the type of command invoked from gridview.
In this event we have to handle the Delete Button Code. Value ; Place the Textbox control in the grids Footer template for Adding new record. Register events for Edit, Update, Cancel button of gridview??
View in GridView To view data in gridview is very simple. IsPostBack block to fill the grid by default. To switch the normal mode to Edit mode of gridview EditIndex property plays important role. EditIndex specifies which row is in edit mode by setting RowIndex to it. By default EditIndex of gridview is -1 Normal mode. If you want to edit 3rd Row then set the EditIndex to 2 Row index starts from 0,1, After setting editindex refresh the grid by calling BinGrid.
GridViewEditEventArgs object knows the current row index so getting row index of the selected row in gridveiw is not big deal; just e. Find the Unique id for updating the row from DataKeys collection of gridview. Value ; Find the controls in the selected row by using FindControl method of gridviews rows collection and collect data from the text boxes. FindControl "txtDesignation" as TextBox; if txtname! Find the Unique id for deleting the row from DataKeys collection of gridview.
Check for CommanName and invoke delete method for the selected row. I added textboxes and a add button in the footer row of the gridview. When u are in Normal mode it is visible else it is invisible to synchronize between edit and add. Like Updating find the Textbox and pass the values to Addemployee method like else if e. The code should be in RowCommand event only.
Due to this we use CommandName for different button control to differentiate between the type of code to be handled by gridview.