简体   繁体   English

动态创建和访问控制值

[英]Creating and accessing control values dynamically

I have a DropDownList that gets populated from SQL on page load. 我有一个DropDownList,它在页面加载时从SQL填充。

A user will select an item from the list and click a button. 用户将从列表中选择一个项目,然后单击一个按钮。

Based upon the item selected, I need to fetch data from SQL. 根据选择的项目,我需要从SQL提取数据。 The results are then used to dynamically create a table with textboxes (for user input). 然后将结果用于动态创建带有文本框的表(供用户输入)。

After filling out some textboxes, the user will click another button. 填写一些文本框后,用户将单击另一个按钮。 I will need to loop through the dynamically created table and do some data processing with the values entered in the textboxes. 我将需要遍历动态创建的表,并使用在文本框中输入的值进行一些数据处理。

I'm having a hard time knowing when to create the dynamic table. 我很难知道何时创建动态表。 If on Page_Init, how do I get the DropDownList selected value to pass to SQL? 如果在Page_Init上,如何获取DropDownList选定值传递给SQL? If on Page_Load, how am I going to re-create the the table with the user-entered values? 如果在Page_Load上,如何使用用户输入的值重新创建表?

This is in C# .NET Framework 4.0 using Webforms 这是在使用Webforms的C#.NET Framework 4.0中

Found the solution. 找到了解决方案。 I'm using Request.Form[ddl.UniqueID] to get the DDL's selected value. 我正在使用Request.Form [ddl.UniqueID]获取DDL的选定值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM