在ASP.NET中动态创建控件 [英] Dynamically creating controls in asp.net

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

问题描述

我正在研究asp.net项目.
我有一个包含面板的ASP页面.
在此面板中,我具有以下控件.第一次将其创建为设计

Start_date_Calendar扩展程序end_date_CalendarExtender单选按钮默认值

第一行是设计部分,我已经创建了它.
第二行以后应该动态生成行
我必须在这些控件的右边添加一个添加按钮,并且当用户单击添加按钮时,上面的行应该会动态生成,现在结构将是

Start_date_Calendar扩展程序end_date_CalendarExtender单选按钮默认Addbtn Start_date_Calendar扩展程序end_date_CalendarExtender单选按钮默认Addbtn
Start_date_Calendar扩展程序end_date_CalendarExtender单选按钮默认Addbtn Start_date_Calendar扩展程序end_date_CalendarExtender单选按钮默认Addbtn

Savebtn

因此,在每个添加按钮上单击均应生成新行

最后,所有这些数据都应保存在保存按钮上,点击
我已经在aspx页面上的设计中创建了这一行.
但是在添加btn时,单击如何动态创建这些控件?
这些行中的单选按钮应该是一组,即如果有5行,则用户只能选择一个单选按钮.
如何保存这些数据?

我不知道该怎么做?
有人可以帮我吗?

I m working on asp.net project.
I have a asp page which contains a panel.
In this panel i have following controls.For first time i create it as design

Start_date_Calendar extender end_date_CalendarExtender radiobuttondefault

First row is design part and i have created it.
Second onwards rows should get dynamically generated
I have to add one add button at right of these controls and when user clicks the add button the above row should get be dynamically generated and now structure will be

Start_date_Calendar extender end_date_CalendarExtender radiobuttondefault Addbtn Start_date_Calendar extender end_date_CalendarExtender radiobuttondefault Addbtn
Start_date_Calendar extender end_date_CalendarExtender radiobuttondefault Addbtn Start_date_Calendar extender end_date_CalendarExtender radiobuttondefault Addbtn

Savebtn

thus on each add button click new row should get generated

and finally at last this all data should get saved on save button click
I have created this row in design that is on aspx page.
But on add btn click how to create these controls dynamically?
And the radio buttons in these rows should be a single set that is if there are 5 rows, user should be able to select only one radio button.
How to save this data?

I m not getting how to do this?
Can someone help me?

推荐答案



要添加行,可以使用数据表并添加行.

要检查单选按钮,请在rowbound方法中编写javascript,以便您可以使用验证该部分.

为了保存网格,请使用for循环从网格中提取数据.

希望对您有所帮助.
Hi,

To add the rows you can use the datatable and add the rows.

For checking the radio button, write the javascript in the rowbound method so that you can use validate that part.

For saving the grid use for loop for extracting the data in grid.

I hope this will help you.


您需要使用GridView的RowTemplate.根据需要设计行,并将其添加为新行"的模板.请参见此处 [ BindingSource 上阅读. [^ ]和数据表.
You need to use the RowTemplate of the GridView. Design the row as you have and add it as the template for New Row. See here[^]
Make the radio button part of your row template.
For displaying and saving data, you would need to read up on BindingSource[^] and data tables.


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

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