和这个差不多
http://www.cnblogs.com/huangbaoyu/articles/1058740.html
图片如下:我在前台用js添加了很多文本框,如图,我在后台要一起获得这个里面的值然后进行每一条记录保存,不知道该怎么做。
下面是页面的代码:<%@ Page Language="C#" MasterPageFile="~/Page/Generic/Generic.master" AutoEventWireup="true"
CodeFile="AddPlan.aspx.cs" Inherits="Page_MonthPlan_AddPlan" Title="Untitled Page" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cph" runat="Server">
<strong><span style="font-size: 10pt">周计划填报: </span></strong>
<div align="center">
<table border="1" cellspacing="1" style="border-collapse: collapse" width="100%">
<tr>
<td colspan="2">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblWeek" runat="server" Font-Size="Medium"></asp:Label> <asp:Calendar
ID="Calendar1" runat="server" BackColor="Honeydew" BorderColor="White" Font-Names="Verdana"
Font-Size="9pt" ForeColor="Black" Height="190px" Width="350px" BorderWidth="1px"
NextPrevFormat="FullMonth" OnSelectionChanged="Calendar1_SelectionChanged">
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="#333333" Font-Bold="True" VerticalAlign="Bottom" />
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<TitleStyle BackColor="White" Font-Bold="True" Font-Size="12pt" ForeColor="#333399"
BorderColor="Black" BorderWidth="4px" />
</asp:Calendar>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblAlert" runat="server" ForeColor="Red" Text="本月无任何记录!"></asp:Label></td>
</tr>
</table>
<table border="1" cellspacing="1" style="border-collapse: collapse" width="100%"
id="tb">
<tr>
<td style="height: 17px">
序号</td>
<td style="height: 17px">
工作计划</td>
<td style="height: 17px">
责任人</td>
<td style="height: 17px">
预计完成时间(年/月/日)</td>
<td style="height: 17px">
本周预计完成进度</td>
<td style="height: 17px">
完成情况</td>
<td style="height: 17px">
自我打分</td>
<td style="height: 17px">
综合部评分</td>
<td style="height: 17px">
删除</td>
</tr>
<%-- <input id="Hidden1" name="Hidden1" type="hidden" value="" />
--%>
</table>
<div align="right" id="DIV1" runat="server">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<input type="submit" name="submit" onclick="getsub()" value=" 确定保存 " />
<input name="button" type="button" onclick='additem("tb")' value=" 新增一条工作计划 " />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div> <script language="javascript" type="text/javascript">
var count=0 ;
function additem(id)
{
var row,cell,str;
row = document.getElementById(id).insertRow();
if(row != null )
{
cell = row.insertCell();
cell.innerHTML=count;
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\" >";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<input type=\"button\" value=\"删除\" onclick=\'deleteitem(this);\'>";
count ++;
}
}
function deleteitem(obj)
{
var curRow = obj.parentNode.parentNode;
tb.deleteRow(curRow.rowIndex);
} function getsub()
{
var re="";
for (var i = 0 ;i<count;i++)
{
re += document.getElementsByName("St"+i)[0].value;
}
document.getElementById("Hidden1").value=re;
}
</script></asp:Content>
http://www.cnblogs.com/huangbaoyu/articles/1058740.html
图片如下:我在前台用js添加了很多文本框,如图,我在后台要一起获得这个里面的值然后进行每一条记录保存,不知道该怎么做。
下面是页面的代码:<%@ Page Language="C#" MasterPageFile="~/Page/Generic/Generic.master" AutoEventWireup="true"
CodeFile="AddPlan.aspx.cs" Inherits="Page_MonthPlan_AddPlan" Title="Untitled Page" %><%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cph" runat="Server">
<strong><span style="font-size: 10pt">周计划填报: </span></strong>
<div align="center">
<table border="1" cellspacing="1" style="border-collapse: collapse" width="100%">
<tr>
<td colspan="2">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lblWeek" runat="server" Font-Size="Medium"></asp:Label> <asp:Calendar
ID="Calendar1" runat="server" BackColor="Honeydew" BorderColor="White" Font-Names="Verdana"
Font-Size="9pt" ForeColor="Black" Height="190px" Width="350px" BorderWidth="1px"
NextPrevFormat="FullMonth" OnSelectionChanged="Calendar1_SelectionChanged">
<SelectedDayStyle BackColor="#333399" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="#333333" Font-Bold="True" VerticalAlign="Bottom" />
<DayHeaderStyle Font-Bold="True" Font-Size="8pt" />
<TitleStyle BackColor="White" Font-Bold="True" Font-Size="12pt" ForeColor="#333399"
BorderColor="Black" BorderWidth="4px" />
</asp:Calendar>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lblAlert" runat="server" ForeColor="Red" Text="本月无任何记录!"></asp:Label></td>
</tr>
</table>
<table border="1" cellspacing="1" style="border-collapse: collapse" width="100%"
id="tb">
<tr>
<td style="height: 17px">
序号</td>
<td style="height: 17px">
工作计划</td>
<td style="height: 17px">
责任人</td>
<td style="height: 17px">
预计完成时间(年/月/日)</td>
<td style="height: 17px">
本周预计完成进度</td>
<td style="height: 17px">
完成情况</td>
<td style="height: 17px">
自我打分</td>
<td style="height: 17px">
综合部评分</td>
<td style="height: 17px">
删除</td>
</tr>
<%-- <input id="Hidden1" name="Hidden1" type="hidden" value="" />
--%>
</table>
<div align="right" id="DIV1" runat="server">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<input type="submit" name="submit" onclick="getsub()" value=" 确定保存 " />
<input name="button" type="button" onclick='additem("tb")' value=" 新增一条工作计划 " />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div> <script language="javascript" type="text/javascript">
var count=0 ;
function additem(id)
{
var row,cell,str;
row = document.getElementById(id).insertRow();
if(row != null )
{
cell = row.insertCell();
cell.innerHTML=count;
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\" >";
cell = row.insertCell();
cell.innerHTML="<textarea id=\"St"+count+"\" STYLE=\"overflow:hidden;border:0;width:100%\" rows=\"3\" name=\"St"+count+"\" value= \""+count+"\">";
cell = row.insertCell();
cell.innerHTML="<input type=\"button\" value=\"删除\" onclick=\'deleteitem(this);\'>";
count ++;
}
}
function deleteitem(obj)
{
var curRow = obj.parentNode.parentNode;
tb.deleteRow(curRow.rowIndex);
} function getsub()
{
var re="";
for (var i = 0 ;i<count;i++)
{
re += document.getElementsByName("St"+i)[0].value;
}
document.getElementById("Hidden1").value=re;
}
</script></asp:Content>
解决方案 »
- 无法将类型“int”隐式转换为“System.Data.SqlClient.SqlDataReader”?怎么解决?
- 求一个函数 把日期转换成16进制(正则函数都行)
- 我写的一个模仿伽尔顿板的实验
- 添加FileUpload控件后单击按钮时出错
- 求助,创建word文档的问题~
- 怎样将数据集传给存储过程
- 我要怎样在WinForm控件中或ASP.NET中引用样式表中的样式
- 用C#怎样做一个这样的代理服务软件?高手请进
- System.IO.FileNotFoundException问题求解
- C#操作MySQL异常
- C#的Hook实例...大家帮帮修改一下我所要的效果,功能...因为我对Hook不了解...去MSDN查了也不了解怎么用...
- 问个关于抓取网页的问题
$cell1,cell2,cell3$cell4,cell5,cell6$cell7,cell8,cell9到了服务器先split('$'),就能得到每行的数据, 然后每行的数据再split(','),就能得到每个单元格的数据了.还要考虑用户输入的字符中是否包含$或, 如果包含, 则替换掉
1.首先你建一个多维数组
2.把填写的内容写到数组,这样可以在你提交之前自己对数据的一个过滤,写一个自己的函数防止sql注入。
3.把内容读入限期控件,这步和楼上的相同。
4.要么你就把内容写到一个xml文件。再在服务器端读取数据。