How can i add edit boxes, and read their values during submit, with an asp:Repeater?
i have an asp:GridView which is displaying a rea
Have you tried by setting up the EditIndex property of the DataGrid?
Example:
Code behind
protected void grdProducts_RowEditing(object sender, GridViewEditEventArgs e)
{
this.grdProducts.EditIndex = e.NewEditIndex;
This.BindGrid();
}
Note that you have to re-bind your grid
Usually you save the data per row, which means, you have an edit link in each row and after you enter edit mode, a save button and optionally a cancel button appear which will allow you to save the values of that specific row
Following this approach is trivial when using the GridView:
protected void grdProducts_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
// old values for the current row
var oldValues = e.OldValues;
// new (updated) values for the current row
var newvalues = e.NewValues;
// Exit edit mode
this.grdProducts.EditIndex = -1;
// Update the grid
this.BindGrid();
}
In the grid markup just add the following:
onrowupdating="grdProducts_RowUpdating"
If you need to specify custom controls when editing or when displaying the cell data in read-only mode, use grid templates: