如何检索动态表中的控件内容?
我有一个页面,我想收集有关 x
个用户的信息。我有一个控件,您可以在其中输入用户数,并根据该数字创建一个动态表,其中每个用户都有一行。每个表行都有文本框控件,我想在回发时从中检索值。如何才能做到这一点?
I have a page where I would like to collect information about x
number of users. I have a control where you enter in the number of users and based off of that number, I create a dynamic table with a row for each user. Each table row has textbox controls that I would like to retrieve the value from on postback. How can this be accomplished?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的目标是哪种特定风格的 ASP.Net? ASP.NET MVC?网络表格?
在 Web 表单(我更熟悉)中执行此类操作的最快、最简单的方法是在页面上放置一个 GridView 控件,并将一个通用集合绑定到它,您可以根据输入的数字设置其大小控制。
这是一段 10m 的快速代码。在 Visual Studio 2010 中创建了一个默认的 WebForms Web 项目。
网页来源:
隐藏代码:
What particular style of ASP.Net are you targeting? ASP.Net MVC? Webforms?
The quickest and easiest way to do something like this in webforms (which Im way more familiar with) would be to drop a GridView control on the page, and bind a generic collection to it that you set the size of based on the number entered in the control.
Here's a quick 10m piece of code. Created a default WebForms Web project in Visual Studio 2010.
Web Page Source:
Code behind:
您可能会发现创建 asp:GridView 更容易。然后,您可以迭代回发时的行并检查控件。那里有很多示例代码。
You may find it much easier to create an asp:GridView instead. You can then iterate through the rows on postback and inspect the controls. Lots of example code out there.