Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

How to delete a button control?

Posted on 2007-10-09
2
Medium Priority
?
176 Views
Last Modified: 2010-04-15
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


0
Comment
Question by:waqarali1999
2 Comments
 
LVL 7

Accepted Solution

by:
Abu Hamdan earned 750 total points
ID: 20044679
Can u place the code that you call this sub from ,, it should work in every call ,, why u have to destroy the controls?
0
 

Author Comment

by:waqarali1999
ID: 20046085
I need to pass different  CommandArgument  everytime.  btnSubmitPost.CommandArgument = ID.ToString();
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question