|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
can i assign a name for a control dynamically?hi ladies and gentlemen
how can i call a control dynamically? for example for(i=1;i<10;i++) { "label" + i + ".text" =i*2; } thanks "miladha***@gmail.com" wrote: try FindControl method.> hi ladies and gentlemen > how can i call a control dynamically? > for example > for(i=1;i<10;i++) { > "label" + i + ".text" =i*2; > } > thanks > > hi klesh
may i ask you just a bit explain how can i do that ? thanks I don't understand what you mean by 'assign a name for control dynamically'
but if you want to construct id of your controls as a string you should use FindControl as follows. for (int i = 1; i < 10; i++) { Label lb = Page.FindControl(String.Format("label{0}", i)) as Label; if (lb != null) { lb.Text = i * 2; } } Regards, Ladislav Mrnka
How to know the selected row in a DataControlField
Validation Groups and Wizard step DetailsView Default Mode Why does OnClick event not work in 2.0 for DataGrid site maps & menu control UpdatePanel, Postback Customising the CatalogZone class Why doesn't work DataFormatString for GridView.BoundField ? tie ENTER to a button? wrong TreeView node selected |
|||||||||||||||||||||||