如何通过aspx动态创建TextBox? [英] How to create a TextBox dynamically by aspx?
本文介绍了如何通过aspx动态创建TextBox?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
早上好。
朋友们,我想帮助创建一个动态属性ID的文本框。
我需要控件ID的名称来自数据库。这样的事情:
Good Morning.
Friends, I would like some help to create a textbox with property ID dynamic.
I need the control ID has the name rescue from database. Something like this:
<asp:TextBox ID='<%# Eval("ST_DESCRICAO") %>' runat="server" Width="100%">
</asp:TextBox>
an d代码隐藏:
myDataList.FindControl(nameoftext);
有可能吗?我的控件是在DataList上。
谢谢。
and in codebehind:
myDataList.FindControl("nameoftext");
Is it possible? My control is on a DataList.
Thanks.
推荐答案
你总能像这样动态添加它
You can always add it dynamically like this
TextBox tb=new TextBox();
tb.ID = //get ID from database;
希望这有帮助
Hope this helps
访问这里..
http://www.aspsnippets.com/articles/creating-dynamic-textbox-controls-in-asp.net.aspx [ ^ ]
或
http://stackoverflow.com/questions/6489395/to-generate-textboxes-dynamically-in-asp-net [ ^ ]
visit here..
http://www.aspsnippets.com/articles/creating-dynamic-textbox-controls-in-asp.net.aspx[^]
or
http://stackoverflow.com/questions/6489395/to-generate-textboxes-dynamically-in-asp-net[^]
< br>
TextBox textbox2 = new TextBox();
textbox2.ID = "textbox2";
textbox2.Style["Position"] = "Absolute";
textbox2.Style["Top"] = "40px";
textbox2.Style["Left"] = "110px";
这篇关于如何通过aspx动态创建TextBox?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文