动态控制 [英] Dynamic controls

查看:71
本文介绍了动态控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最初,我有一个下拉列表和文本框,并添加了按钮控件
在控件中填充数据后,如果我单击添加按钮,则必须动态生成另一个下拉列表和文本框控件,并添加用于生成另一组动态控件的添加按钮
最后,我将保存所有数据通过保存"按钮

我不知道如何完成此任务对我有帮助?

initially i have one dropdown and textbox and add button control
After filling data in controls if i click on add button i has to generate dynamically another dropdown and textbox controls and add button for generating another set of dynamic controls
finally i will save all the data trough save button

i dont know how to complete this task help me?

推荐答案

[^ ]可能会为您提供帮助.
This[^] may just help you.


您可以在客户端使用某些JavaScript的cloneNode来执行此操作.或在服务器上使用类似的内容

You could either do this on the client with some JavaScript, cloneNode. Or on the server with something like this

protected void OnButtonClick(...)
{
   DropDownList ddl = new DropDownList();
   Controls.Add(ddl);

   TextBox txt = new TextBox();
   Controls.Add(txt);
}



两种情况都不需要添加更多按钮.请记住,尽管使用服务器方法,您必须跟踪并重新创建动态添加到页面的每个控件.



There is no need it either case to add more buttons. Keep in mind though with the server method you must keep track of and recreate each control that was dynamically added to the page.


这篇关于动态控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆