求助:一个简单的问题

lannypayne 2008-11-10 03:29:47



如上图
我的需求是 拉选那个下拉框 取得一个数字
随后在table的地方生成表格 若选的是4 则出来4个表格
表格中会有textbox
最后在按button的时候 把所有表格里的所有textbox里的值存到数据库里

大家来帮帮我 我用Response.Write好象不能实现`~~
小弟不明白了

谢谢大家先
...全文
94 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Sugar_Tiger 2008-11-11
  • 打赏
  • 举报
回复
友情UP,顺便接分
风骑士之怒 2008-11-10
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 kkun_3yue3 的回复:]
Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
//全局静态的链…
[/Quote]

up,动态生成,如果需要无刷新,在外面套一个updatepanel控件,如果你用VS2008的话,或者已经有ms ajax 1.0,希望对你有帮助,=.=
kkun_3yue3 2008-11-10
  • 打赏
  • 举报
回复
Default.aspx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class _Default : System.Web.UI.Page
{
//全局静态的链表
public static ArrayList list = new ArrayList();

protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{
//添加
list.Clear();
for (int i = 0; i < Convert.ToInt32(TextBox1.Text); i++)
{
TextBox t = new TextBox();
t.ID = "text " + i;
list.Add(t);
Panel1.Controls.Add(t);
}
}
protected void Button2_Click(object sender, EventArgs e)
{
//取值
string s = " ";
for (int i = 0; i < list.Count; i++)
{
TextBox TextBox1 = (TextBox)list[i];
s += "第 " + (i + 1).ToString() + "个文本框的值是: " + Request[TextBox1.ID] + "\r\n ";
}

TextBox2.Text = s;
}

}


Default.aspx

<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html xmlns= "http://www.w3.org/1999/xhtml " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
生成控件的个数: <asp:TextBox ID= "TextBox1 " runat= "server "> 1 </asp:TextBox>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "生成 " />
<asp:Panel ID= "Panel1 " runat= "server " BackColor= "#E0E0E0 " Height= "173px " Width= "545px ">
</asp:Panel>

</div>
<asp:Button ID= "Button2 " runat= "server " OnClick= "Button2_Click " Text= "取值 " />
<br />
<asp:TextBox ID= "TextBox2 " runat= "server " Height= "211px " TextMode= "MultiLine " Width= "538px "> </asp:TextBox>
</form>

</body>
</html>


WebUserControl.ascx

<%@ Control Language= "C# " AutoEventWireup= "true " CodeFile= "WebUserControl.ascx.cs " Inherits= "WebUserControl " %>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>


WebUserControl.ascx.cs

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{

}
}
CCppMfc 2008-11-10
  • 打赏
  • 举报
回复
up
lannypayne 2008-11-10
  • 打赏
  • 举报
回复
这个js怎么写。。。
我中间要出来3个text 空的 需要用户填写的
如果上面下拉框选了4 那就是12个text了 这些数值都要存的`
refeiner 2008-11-10
  • 打赏
  • 举报
回复
用JS写,直接写HTML表格,比较方便
luoyinshuang 2008-11-10
  • 打赏
  • 举报
回复
你的表格有什么要求没有?

方法一、如果是很规范的列,用个GridView 。
比如执行条查询语句,随便找个表,select top 4 id from 表名
再绑定到GridView上面。

方法二、页面上定义一个变量,格式<%=变量名%>
后台申明下,public string 变量名;

再在按钮事件里写表格的html;

第一个方法简单,
第二个方法灵活,而且做出来的样式漂亮。
卧_槽 2008-11-10
  • 打赏
  • 举报
回复
用js写
很简单的。

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧