且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将多行插入数据库&可以放在循环部分中

更新时间:2023-12-04 13:23:16



我为您编写了一些代码.请一次检查

也许这就是您想要的

Hi,

I write some code for you.check this once

May be this is what you want

<asp:panel id="Panel1" runat="server" xmlns:asp="#unknown">
    <asp:textbox id="TextBox1" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox2" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox3" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox4" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox5" runat="server"></asp:textbox><br />
    <asp:textbox id="TextBox6" runat="server"></asp:textbox><br />
</asp:panel>
<br />
<asp:button id="Button1" runat="server" text="Button" onclick="Button1_Click" xmlns:asp="#unknown" />



文件后面的代码包含以下代码



And code behind file contains following code

    protected void Button1_Click(object sender, EventArgs e)
    {
        List<textbox> txtboxlst = new List<textbox>();
        foreach (Control c in Panel1.Controls)
        {
            if (c is TextBox)
            {
                txtboxlst.Add((TextBox )c);
            }
        }
        string str1 = txtboxlst[0].Text;
    }
</textbox></textbox>




现在告诉我你到底想要什么

***的




Now tell me what exactly you want

All the Best



首先,将Children的所有详细信息存储在Temp Datatable中
说Dt ...
现在您可以访问dt的每个单元格,因此您可以将此详细信息存储在相应的数据库表中
Hi,
First Of all take All the details Of Children And Store it in Temp Datatable
Say Dt...
Now You can Access Each cell of dt Accordingly you can store this Details In Respective Database Table
table = (DataTable)Session["Temp_Product_Table"];

                     for (int i = 0; i < table.Rows.Count; i++)
                     {
                         string cmd_Insert_Product_In_Db = "INSERT INTO IWO_Product_List(iwo_no,product,model,price,vat,excise,other_tax,amount) Values('" + table.Rows[i][1] + "','" + table.Rows[i][2] + "','" + table.Rows[i][3] + "','" + table.Rows[i][4] + "','" + table.Rows[i][5] + "','" + table.Rows[i][6] + "','" + table.Rows[i][7] + "','" + table.Rows[i][8] + "')";
                         MIS_DAL.ExecuteNonQuery(cmd_Insert_Product_In_Db, "query");

                     }