Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding objects with Event Handlers in run-time
Message
 
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
ASP.NET
OS:
Windows XP
Database:
MS SQL Server
Miscellaneous
Thread ID:
01315893
Message ID:
01315912
Views:
23
I chose a simpler route and just added this button in design-time.

>Hi everybody,
>
>I have the following code
>
>protected void ProfilesGrid_RowDeleted(object sender, GridViewDeletedEventArgs e)
>    {
>        if (e.Exception == null)
>        {
>            LinkButton UndoDel = new LinkButton();
>
>            this.roundedStat.Style["display"] = "block";
>            this.lblStatus.Text = "Removed " + e.Values["FirstName"] + " " + e.Values["LastName"] + " click to ";
>            UndoDel.Text = "Undo";
>            UndoDel.CommandName = "Undelete";
>            UndoDel.CausesValidation = false;
>            UndoDel.CommandArgument = e.Keys["RegistrationID"].ToString();
>            UndoDel.Command += new CommandEventHandler(UndoDel_Command);
>            this.plchStatusControls.Controls.Add(UndoDel);
>            this.ClientScript.RegisterStartupScript(this.GetType(), "HighlightMess", " Effect.Pulsate('round',1,0.7);", true);
>        }
>    }
>
>    protected void UndoDel_Command(object sender, CommandEventArgs e)
>    {
>       if (e.CommandName.CompareTo("Undelete") == 0)
>        {
>            string SQL = "UPDATE Registration SET Deleted = 0 WHERE RegistrationID = " +
>                e.CommandArgument;
>            Util.DoCmd(SQL);
>            this.ProfilesGrid.DataBind();
>            this.HideForm(sender, (EventArgs)e);
>        }
>    }
>
>So, it looks like the button is supposed to be added in run-time with the event handler.
>
>However, placing break points into the UndoDel_Command method doesn't go there. When I click on the Undo button the status panel disappers, but nothing happens. (The person doesn't get undeleted).
>
>Do you see what may be wrong here?
>
>My colleague solved this problem by adding the UndoDel_Command into OnPrerender of the page and saving PersonID in the class property, but this doesn't seem like a correct solution to me.
>
>Do we add Event Handler in run-time the right way here? Why I can not debug it?
>
>Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform