简体   繁体   English

动态为输入表单创建文本框和下拉框

[英]Dynamically Creating Textboxes and DropDown Boxes for input form

I am working on a Nutrition Program that would allow a user to enter in the nutrition information for a item. 我正在制定一项营养计划,该计划将允许用户输入食品的营养信息。 营养网格

this is what my input form looks like every time a user clicks the plus button I need to create three new text boxes and a drop down box which would look like the above example. 这就是我每次用户单击加号按钮时的输入表单,我需要创建三个新的文本框和一个下拉框,类似于上面的示例。 在此处输入图片说明

This is what I am using right now but it only creates the textboxes for the first click. 这就是我现在正在使用的内容,但是它只会为第一次单击创建文本框。 I need create the textboxes and combo boxes on every time the user clicks the add button. 每次用户单击添加按钮时,我都需要创建文本框和组合框。

Nvm, Nvm,

I managed to do this myself using ViewStates it took alot of code but it works this is adding the controls on button click. 我设法使用ViewStates自己进行了此操作,它花费了很多代码,但是它的工作原理是在按钮单击时添加控件。

在此处输入图片说明

This is re-adding the controls on postback 这是在回发时重新添加控件

在此处输入图片说明

And this is the results 这就是结果 在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM