Link to home
Start Free TrialLog in
Avatar of waqarali1999
waqarali1999

asked on

How to delete a button control?

I have following code:

 private void BuildPostSurveyQuestionTable(int ID)
   {
// I create a new  table here each time whenever I call this BuildPostSurveyQuestionTable



               HtmlTableCell cellCommand;
               HtmlTableRow rowCommand;
               ValidationSummary valsum = new ValidationSummary();
               valsum.ValidationGroup = "submit";
               valsum.ShowMessageBox = false;
               valsum.ShowSummary = false;
               cellCommand = new HtmlTableCell();
               cellCommand.ColSpan = 3;
               cellCommand.Align = "right";
               Label lblSubmitStatusPost = new Label();
               lblSubmitStatusPost.ID = "lblSubmitStatusPost";
               Button btnSubmitPost = new Button();
               btnSubmitPost.Text = "Save";
               btnSubmitPost.CommandArgument = ID.ToString();
               btnSubmitPost.Click += new EventHandler(btnSubmitPost_Click);
               btnSubmitPost.ValidationGroup = "submit";
               cellCommand.Controls.Add(valsum);
               cellCommand.Controls.Add(lblSubmitStatusPost);
               cellCommand.Controls.Add(btnSubmitPost);
               rowCommand = new HtmlTableRow();
               rowCommand.Cells.Add(cellCommand);
               tblEvaluation.Rows.Add(rowCommand);

}
I have to call this code multiple times. But its works fine the first time only, when I call it second time it doesn't jump on btnSubmitPost_Click(),  after clicking the button it should jump to btnSubmitPost_Click()  every time but why it only works for first survey only and not  for the second one? Do I need to destroy btnSubmitPost control everytime? how do i do this?

how do I create a control with the same name again?  how do I destroy the previous one?

Thanks


ASKER CERTIFIED SOLUTION
Avatar of Nasser Hamdan
Nasser Hamdan
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of waqarali1999
waqarali1999

ASKER

I need to pass different  CommandArgument  everytime.  btnSubmitPost.CommandArgument = ID.ToString();