gridview中的动态行生成, [英] dynamic row generaton in gridview ,,

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

问题描述

我正在使用C#,asp.net 2.0,Server 2005和Visual Studio 2005

任何人都可以帮助以下Gridview设计.

最初,我使用数据库值加载gridview,这是可行的.

现在,当用户单击添加新行"按钮时,我应该能够动态添加具有5个文本框的gridview.

每行必须有一个添加,删除,编辑按钮,该按钮在数据库中执行相应的操作,

当用户单击另一个按钮时,我应该能够添加新行.添加新行(按钮).

所有这些按钮单击事件应反映数据库中的更改.


请帮帮我.

在此先感谢.
问候,

Karan

I am using C#,asp.net 2.0,server 2005 and visual studio 2005

Can anybody help with the following Gridview design .

Initially i load gridview with the database values this is working.

Now when the user clicks add new row button, I should be able to add gridview with 5 textboxes dynamically.

At each row there must be a add,delete,edit button that performs corresponding operations in the database,

I should be able to add new row when the user clicks on another button add new row(button) .

All these button click event should reflect the changes in the database .


please help me.

Thanks in Advance.
Regards,

Karan

推荐答案

您可以将当前网格数据保留在数据表中并将其绑定到网格.
添加新行后,插入到数据表中并重新绑定网格.

希望这会给您一个想法.
You can keep the current grid data in a data table and bind it to the grid.
When a new row is added insert in to the data table and rebind the grid.

Hope this will give you an idea.


卡兰

请按照以下步骤实现您的目标

1)保持自动生成列为false

2)在gridview列属性中,使用超链接"创建一个模板"字段并将其命名为添加行"

3)手动创建带有文本框的GridView列,然后将其禁用,然后单击Addrows超链接将其激活并将其更改为Submit Hyperlink并保留数据并保留一个Submit链接,还可以通过页面事件和onrowdatabound来实现上述功能,onrowcommand和pageindexing方法.

5)在相应事件中使用ado.net并提交数据并禁用手动网格视图行
hi Karan

Follow the following steps to acheive your goal

1)keep autogenerate columns to false

2)In gridview column properties Create a Template field with Hyperlink and name it as Add rows

3)Manually Create the GridView Columns with Textboxes you require and disable it and once you click on the Addrows hyperlink activate it and change that to Submit Hyperlink and capure the data and keep one submit link alsoyou can do the above function through page events and onrowdatabound ,onrowcommand and pageindexing methods.

5)use ado.net in the respective event and submit the data and disable the manual grid view row


添加新行:
您需要使用DataGrid的数据源.只需在数据源中添加新项并重新绑定数据网格即可.
For adding new row:
You need to play with DataGrid''s datasource. Just add new item in the datasource and rebind the datagrid.


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

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