In the above declaration, I have set up some Template Fields columns so that GridView will automatically generate a row of DropDownLists when a new row is being added.You would also notice that I have added a Button Control under the FooterTemplate at the last column in the GridView.
Therefore, we will add a column named “Qualification” to the GridView, which will have a DropDownList. The DropDownList will get its data from a master table in the database.
A method that adds a new row to the GridView when a Button is clicked and store the newly added row values in the Original Table that was defined in the SetInitialRow() method. SetPreviousData(). A method that retains all the items that was selected from the DropDownList when it postbacks.
DropDownList ddl1 = (DropDownList)Gridview1.Rows[rowIndex].Cells.FindControl("DropDownList1")
GetDropDownData will be a protected method in code-behind that will return the data (data-table, list, array) for the given row. You can use GridView.RowDataBound event (or RowCreated event) in code-behind to fill drop-downs.
in Pager's Row of our GridView add a TableCell.
As you can see from the markup above, I have setup a BoundField for displaying the RowNumber and some TemplateField columns so that the GridView will automatically generate a row of TextBoxes and DropDownLists when adding a new row.
The following program shows how to add a blank row between gridview rows. Database.
of new records to the database from the footer row of the GridView control.
I used the GridView_RowDataBound event to populate the DropDownList. Take a look at the method below