最简单的方法来添加在ASP.NET Web窗体多行数据 [英] Easiest way to add multiple rows of data in ASP.NET Web Forms

查看:114
本文介绍了最简单的方法来添加在ASP.NET Web窗体多行数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有包含HTML行的ASP.NET Web窗体:组合框和几个文本框。我需要让用户选择一个值从组合框,然后在文本框中填写。他们这样做,我希望他们可以点击添加或类似的东西,这些数据添加到网格中。它们应该能够增加这样的任意数或行。他们应该能够删除行,如果他们的愿望。然后,当他们提交表单,我希望能够抓住他们的背后方法code输入的所有数据。

I've got an ASP.NET Web Form with an HTML row containing: a combo box and a few text boxes. I need to let the user select a value from the combo box then fill in the text boxes. After they do that, I'd like them to be able to click "Add" or something like that to add that data to a grid. They should be able to add an arbitrary number or rows this way. They should be able to delete a row if they wish. Then, when they submit the form, I'd like to be able to grab all the data they entered in the code behind method.

什么是做最简单的方法?

What's the easiest way to do this?

推荐答案

如果输入的形式是足够小,那么你可以使用GridView控件或ListView。

If the input form is small enough then you could use gridview or listview.

事情是这样的:

你有你让说GridView和在尾行你能添加单独的项目。当用户通过尾行添加一行,那么你每一个新的项目添加到您的会话存储临时总汇。当用户结束添加行你只是通过存储在会话项目集合进行迭代,并将它们添加到数据库中。

You have your let say gridview and in footer row your enable adding seperate items. When user adds a row through footer row then you add each new item to temporary colletion which you store in session. When user ends adding rows you just iterate through collection of items stored in session and add them to database.

当然这个选项也允许您删除该用户已经增加,不希望将其保存到数据库项目。

Of course this option also allows you to remove items that the user has already added and doesn't want to save them in database.

问候,
乌罗什

Regards, Uros

这篇关于最简单的方法来添加在ASP.NET Web窗体多行数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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