我有以下ASP.Net webform,它有一个按钮,用户可以点击该按钮在表单上生成一堆字段(使用Javascript)。我在表单上也有一堆静态字段,在静态字段上输入的值将传输到SQL表。通过单击按钮传输在生成的字段中输入的值时,我遇到了很大的麻烦。截至目前,我将生成的文本框命名为txtDimension 2&等等。我需要帮助来创建一个SQL字符串循环,它可以帮助我从webform上的生成和静态字段传输值。
这是我的ASP.Net按钮代码:
context.req.query
ASP.Net按钮的Javascript代码,用户单击该按钮以在webform上生成其他字段:
session = requests.Session()
page=session.get(url)
page_data = lxml.html.fromstring(page.text)
float=lxml.html.tostring(page_data).replace('', '')
page_data = lxml.html.fromstring(float)
Webform之后的C#代码,它传输从webform到静态字段中输入的值,我想要生成字段的SQL字符串循环:
<script src="check.js" type="text/javascript"></script>
<div id="divDimensions" class="auto-style9">
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Add More Fields" OnClientClick="return addInput('divDimensions');" CssClass="auto-style10" Height="68px" Width="236px" />
</div>
<p class="auto-style9">
</p>
<p class="auto-style9">
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" Width="191px" Height="82px" />
</p>
答案 0 :(得分:0)
int[] myArray = //whatever;
int[] changedArray = myArray.MoveFirstToLast();
c#
-- for table type to pass to SP
CREATE TYPE [dbo].[NameValuePairTable] AS TABLE( DimensionType [NVARCHAR](MAX) NULL, Dimension [NVARCHAR](MAX) NULL ) GO
-- call SP from C# code and pass it the table type object
CREATE PROCEDURE [dbo].[SaveResultsFromForm]
@NameValuePairAnswers as dbo.NameValuePairTable READONLY
AS
BEGIN
-- this will insert ALL answers from the web form you passed from the c# object
INSERT INTO Checksheets (DimensionType, Dimension)
Select DimensionType, Dimension
FROM @NameValuePairAnswers
END
更新以添加更多c#代码
// now build out the namevalue pair paramater to pass to SP call
SqlParameter TableData = new SqlParameter();
TableData.ParameterName = "@NameValuePairAnswers";
TableData.TypeName = "dbo.NameValuePairTable";
TableData.SqlDbType = SqlDbType.Structured;
// this will be the C# object you populated from your form as a C# datatype DataTable
TableData.Value = FormResultsDataTable;