In gridview control, am using RowEditingevent. I have created a command field to handle insert, cancel and update.
Problem : When click edit (manage.jpg), it is not showing in edit mode. If I do one more click, on the same edit, it is showing data fields to edit. I do not understand why it is not responding for the first click event.
<asp:CommandField
ShowEditButton="true"
ShowCancelButton="True"
ButtonType="Image"
EditImageUrl="manage.jpg"
HeaderText="Edit"
UpdateImageUrl="insert.jpg"
CancelImageUrl="cancel.png"
ItemStyle-Width="10px" >
<ItemStyle Width="20px" Height="20px"></ItemStyle>
</asp:CommandField>
protected void gridFavoriteAddress_RowEditing(object sender, GridViewEditEventArgs e) {
gridFavoriteAddress.EditIndex = e.NewEditIndex;
//gridFavoriteAddress.DataBind();
}
Just some thoughts
When you click on edit the first time does that rebind the grid before the edit event has fired. I have known that disturb the event model
Try adding
CausesValidation="false"to the Command field just in case some failed validation is blockng it the first time throughTry recoding it to use an
ImageButtonwith aCommandName="Edit"in aTemplateColumn. This should also fire the row editing event. Does that one work?This is mad – but you’ve got conflicting styles (widths) in the command button. I would just remove. I know it couldn’t possibly cause it but I would just make sure everything is exactly as it should be when going through this