how to create button dynamically

Posted by Rahul0091 under ASP.NET on 2/20/2012 | Points: 10 | Views : 1097 | Status : [Member] | Replies : 2
hi,

i one table column i have string like this 12,32,43,1,4,6,21
in another table these values ids and their name is given like this
ID | Product_name
1 | pencil
2 | Book
12 | Pen
32 | Computer


now i want to create dynamic 7 button as the values given seperated by commas with the button name like .. Pen Computer . . . . . etc

how to do this
please help me ..

Thankyou..:)

Rahul Gupta


Responses

Posted by: Nishantcomp2512 on: 2/20/2012 [Member] Starter | Points: 25

Up
0
Down
you have to store value in to one array..


string temp="12,32,43,1,4,6,21";
char[] spchar=new char(',');
string[] data=temp.split(spchar);
foreach(dt in data)
{
//for dt check db value put it in a string
string fromdb="";
Page.Controls.Add(new Button("fromdb"));
}


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

Posted by: Hmanjarawala on: 2/20/2012 [Member] Bronze | Points: 25

Up
0
Down
yes, nishant is right...
but if you think about design perspect also...i will suggest to use repeater control...

Himanshu Manjarawala
Sr. Software Engineer@AutomationAnywhere
http://fieredotnet.wordpress.com/

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

Login to post response