This makes no difference if i do this in the binddata() or in the
CreateChildControls(). It have to be reattached every time there will
be a postback. further, there is no cycle there, events are being
called after everything is loaded on a page, like the
CreateChildControls. It is just that they are being reattached.

I have a live demo of my problem: Try it yourselfs:

http://gw2.cezus.nl



On 4 mei, 12:45, Cerebrus <[email protected]> wrote:
> I don't get it at all... Why would you attach your eventhandlers in
> the BindData() method when you call this method from the Eventhandlers
> themselves ?
>
> Don't you see a cycle here ?
>
> On May 4, 2:21 pm, Cezus <[email protected]> wrote:
>
> > Hello,
>
> > I have a problem in my composite control. In this composite control I
> > create a GridView in one of the TableCells of a Table control. This
> > GridView has multiple events on it, such as rowediting event,
> > rowupdating event, rowcancelingedit event.
>
> > image:http://www.cezus.nl/GridView.JPG
>
> > [code]
> >         private void BindData()
> >         {
> >             _gvCategories = (GridView)this.FindControl
> > ("gvCategories");
> >             _dtCategories = (DataTable)HttpContext.Current.Session
> > ["dtCategories"];
>
> >             _gvCategories.DataSource = _dtCategories;
> >             _gvCategories.AutoGenerateDeleteButton = true;
> >             _gvCategories.AutoGenerateEditButton = true;
> >             _gvCategories.RowEditing += new GridViewEditEventHandler
> > (_gvCategories_RowEditing);
> >             _gvCategories.RowUpdating += new GridViewUpdateEventHandler
> > (_gvCategories_RowUpdating);
> >             _gvCategories.RowDeleting += new GridViewDeleteEventHandler
> > (_gvCategories_RowDeleting);
> >             _gvCategories.RowCreated += new GridViewRowEventHandler
> > (_gvCategories_RowCreated);
> >             _gvCategories.RowCancelingEdit += new
> > GridViewCancelEditEventHandler(_gvCategories_RowCancelingEdit);
>
> >             _gvCategories.DataBind();
> >         }
>
> >         void _gvCategories_RowEditing(object sender,
> > GridViewEditEventArgs e)
> >         {
> >             _gvCategories = (GridView)sender;
> >             _gvCategories.EditIndex = e.NewEditIndex;
> >             BindData();
> >         }
>
> >         void _gvCategories_RowUpdating(object sender,
> > GridViewUpdateEventArgs e)
> >         {
> >             _gvCategories = (GridView)sender;
> >             _dtCategories = (DataTable)HttpContext.Current.Session
> > ["dtCategories"];
> >             GridViewRow row = _gvCategories.Rows[e.RowIndex];
>
> >             foreach (DataRow dr in _dtCategories.Rows)
> >             {
> >                 if (dr.RowState != DataRowState.Deleted)
> >                 {
> >                     if (Convert.ToInt32(dr["drID"]) == Convert.ToInt32
> > (((TextBox)(row.Cells[3].Controls[0])).Text))
> >                     {
> >                         dr["ID"] = ((TextBox)(row.Cells[1].Controls
> > [0])).Text;
> >                         dr["Categorie"] = ((TextBox)(row.Cells
> > [2].Controls[0])).Text;
> >                     }
> >                 }
> >             }
> >             _gvCategories.EditIndex = -1;
> >             HttpContext.Current.Session["dtCategories"] =
> > _dtCategories;
>
> >             BindData();
>
> >             Button _btnNieuw = (Button)this.FindControl("btnNieuw");
> >             _btnNieuw.Enabled = true;
>
> >         }
> > [/code]
>
> > If I press on the 'edit' button in the GridView it goes to the
> > rowediting event. If I press after that on the 'update' button it goes
> > again through the rowediting event instead of going through the
> > rowupdating event.
>
> > I am struggling for 2 days with this, I hope somebody knows a
> > solution.
>
> > With Kind Regards,
>
> > Cees van Altena

Reply via email to