Note that there are some explanatory texts on larger screens.

plurals
  1. POEvent wired up 2 times
    text
    copied!<p>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.</p> <p>I have checked about AutoEventWireup, but aspx and ascx are correct (false and OnInit overrided).</p> <p>Event from Gridview are set in Page_Init, but same behavior if it is in Page_Load. I use same event for 2 Gridviews.</p> <p>Some ideas to help me ? </p> <p>Here a sample of my code </p> <pre><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())); } </code></pre> <p>Finally, issues is on CommandField, when it is in ButtonType="Image", Edit or Delete is fired 2 times.</p> <p>Then how use ButtonType with Image ?</p> <p></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload