generate buttons dynamically

Posted by Rahul0091 under ASP.NET on 2/21/2012 | Points: 10 | Views : 1153 | Status : [Member] | Replies : 1

i have one table with some records table like this

WFID clientID WorkflowName workflowsteps completedstep
12 15 print cutting,printing,lamination -

workflowsteps will varry depends upon the workflow name
in completedstep column it will show the completed steps for example: if cutting and printing is done then it will show cutting,printing

now i want to create dynamic buttons with the name cutting, printing, lamination
all the button will be disable by default only first button will be enable and clickable if i press first button "cutting" then its color should changed to red and the next "printing" button will be enable... same process will repeat for each dynamic button..

how to do this in ..
please help me


Rahul Gupta


Posted by: Blessyjees on: 2/21/2012 [Member] Bronze | Points: 25


First you add a placeholder where you add buttons and try below code and make necessary changes
<asp:PlaceHolder ID="phContainer" runat="server"></asp:PlaceHolder>

public partial class WebForm1 : System.Web.UI.Page
Button btnCutting = new Button();
Button btnPrint = new Button();
Button btnLamination = new Button();
protected void Page_Load(object sender, EventArgs e)
btnCutting.Text = "Cutting";
btnCutting.ID = "btnCutting";
btnCutting.Click += new EventHandler(btnCutting_Click);

btnPrint.Text = "Printing";
btnPrint.ID = "btnPrint";
btnPrint.Enabled = false;
btnPrint.Click += new EventHandler(btnPrint_Click);

btnLamination.Text = "Lamination";
btnLamination.ID = "btnLamination";
btnLamination.Enabled = false;
btnLamination.Click += new EventHandler(btnLamination_Click);


protected void btnCutting_Click(object sender, EventArgs e)
btnCutting.BackColor = System.Drawing.Color.Red;
btnPrint.Enabled = true;
protected void btnPrint_Click(object sender, EventArgs e)
btnPrint.BackColor = System.Drawing.Color.Pink;
btnLamination.Enabled = true;
protected void btnLamination_Click(object sender, EventArgs e)
btnLamination.BackColor = System.Drawing.Color.Green;


Blessy Baby
Digitalmesh Softech pvt Ltd

Rahul0091, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response