asp.net 4.0中gridview中的动态数据 [英] dynamic data in gridview in asp.net 4.0

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

问题描述





我已经将数据表动态绑定到gridview的五行。

Girdview包含3个下拉列表和4个下拉列表文本框。

我需要在往返服务器的网格视图中维护数据。

我在更新面板中保留了gridview。



我有一些功能需要在gridview中添加新行。



此时我无法维护前5的数据gridview中的行。



我也试过谷歌,我无法得到解决方案



请帮我解决问题

解决方案

我想你正在寻找像这样的东西:从ASP.NET GridView动态添加和删除行 [ ^ ]


最初你的gridview有5行的数据表。

并且你想在其中添加第6行?对吧?



执行以下操作。



在ViewState中添加5row数据表。



代码中你要添加第六行。



创建另一个数据表。通过viewstate获取5row数据表。



为这个新数据表创建一个新的数据行。



将它添加到它。



现在新的数据表将有6行。



重新绑定你的gridview使用这个新的数据表并将其保存在ViewState中。



编辑:进一步请看看Rohan发布的其他解决方案..它是非常详细的工作代码,我认为这将解决你的问题。 :)





希望它会有所帮助。 :)

Hi,

I have bind the data table with 5 rows dynamically to a gridview.
Girdview consists of 3 dropdownlists and 4 textboxes.
I need to maintain the data in the gridview at roundtrip to the server.
I have kept gridview in update panel.

I have functionality that I need to add new row to the gridview.

At this time I am unable to maintain the data of first 5 rows in gridview.

I have tried in google also, I couldn't get the solution

Please help me in solving the issue

解决方案

I think you are looking for some thing like this one: Dynamically adding and deleting rows from ASP.NET GridView[^]


Initially your gridview is having datatable with 5 rows.
and You want to add 6th row in it?? Right??

do the following.

Add the 5row datatable in ViewState.

in the code where you want to add sixth row.

Create another datatable. get the 5row datatable through viewstate in it.

create a new datarow for this new datatable.

add it in to it.

now new datatable will be having 6 rows.

rebind your gridview with this new datatable and also save this in ViewState.

EDIT: Further Kindly have a look at the other solution posted by Rohan... It is pretty detailed working code with it and I think that would solve your problem. :)


Hope it will help. :)


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

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