将行添加到表单

编程入门 行业动态 更新时间:2024-10-27 01:26:23
本文介绍了将行添加到表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在创建一个订单表格,其中有两个下拉框,这些下拉框将从数据库中填充以供选择,还有一些文本框需要填写(所有框均水平排列) .我希望能够点击添加" 行"按钮并复制所有下拉菜单和文本框,以再次填写,并在订单中添加另一行.我有以下代码,但在弄清楚如何使其能够执行所需功能时遇到了一些麻烦.

I am in the process of creating an order form where I have a couple of drop-down boxes that will be populated from a database to select from and text boxes that need to be filled in (all horizontally alighned). I would like to be able to click an "add row" button and duplicate all of the drop-downs and text boxes to be filled in again and add another line to the order. I have the following code, but I am having a little trouble figuring out how I would make it do what I need.

protected void addNewRow() { // Get Row Count int currentRowCount = 3; // Add 1 to row count string newRowCount = Convert.ToString(currentRowCount++); lblErrorMessage.Visible = true; lblErrorMessage.Text = "Row Count: " + newRowCount; try { // Add button //Button btnSave = new Button(); //pnlTest.Controls.Add(btn); TextBox txtDescription = new TextBox(); txtDescription.ID = "txtDescription" + newRowCount; pnlTest.Controls.Add(txtDescription); } catch (Exception ee) { // Add row error lblErrorMessage.Text = ee.Message.ToString(); } }

推荐答案

如果您使用的是ASP c#,则此问题可能会对您有所帮助:

If you're using ASP c# this question may help you:

如何动态生成TextBox控件.

更多推荐

将行添加到表单

本文发布于:2023-10-10 22:51:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1479982.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!