Hello,
I have an issue with event as Page_Init, Page_Load, there are wired up 2 times when I click on a Gridview inside my page.
I have checked about AutoEventWireup, but aspx and ascx are correct (false and OnInit overrided).
Event from Gridview are set in Page_Init, but same behavior if it is in Page_Load. I use same event for 2 Gridviews.
Some ideas to help me ?
Here a sample of my code
protected override void OnInit(EventArgs e)
{
instance = (IServiceActivity)InterfaceRepository.GetService(typeof(ServiceActivity));
this.Load += new EventHandler(Page_Load);
this.CollectionGridView1.RowDeleting += new GridViewDeleteEventHandler(CollectionGridView1_RowDeleting);
this.CollectionGridView1.RowDataBound += new GridViewRowEventHandler(CollectionGridView1_RowDataBound);
this.CollectionGridView1.RowEditing += new GridViewEditEventHandler(CollectionGridView1_RowEditing);
this.CollectionGridView1.Sorting += new GridViewSortEventHandler(CollectionGridView1_Sorting);
this.CollectionGridView1.PageIndexChanging += new GridViewPageEventHandler(CollectionGridView1_PageIndexChanging);
this.CollectionGridView2.RowDeleting += new GridViewDeleteEventHandler(CollectionGridView1_RowDeleting);
this.CollectionGridView2.RowDataBound += new GridViewRowEventHandler(CollectionGridView1_RowDataBound);
this.CollectionGridView2.RowEditing += new GridViewEditEventHandler(CollectionGridView1_RowEditing);
this.CollectionGridView2.Sorting += new GridViewSortEventHandler(CollectionGridView1_Sorting);
this.CollectionGridView2.PageIndexChanging += new GridViewPageEventHandler(CollectionGridView1_PageIndexChanging);
base.OnInit(e);
}
protected void CollectionGridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
CollectionGridView cgv = (CollectionGridView)sender;
cgv.SelectedIndex = e.RowIndex;
CvrActivity cvrAct = new CvrActivity();
cvrAct = instance.GetActivityById(long.Parse(cgv.SelectedDataKey.Value.ToString()));
if (cvrAct != null)
{
//DELETE
}
}
protected void CollectionGridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
CollectionGridView cgv = (CollectionGridView)sender;
cgv.SelectedIndex = e.NewEditIndex;
base.Modify(long.Parse(cgv.SelectedDataKey.Value.ToString()));
}
Finally, issues is on CommandField, when it is in ButtonType="Image", Edit or Delete is fired 2 times.
Then how use ButtonType with Image ?