コード例 #1
0
    protected void btnImport_Click(object sender, EventArgs e)
    {
        string[]      lstdata        = hdnHeaderRank.Value.Split(':');
        List <string> lstColumnNames = (List <string>)Session["ColumnNames"];

        foreach (GridViewRow gridRow in lstLeadsData.Rows)
        {
            List <string> lstCellColumns    = new List <string>();
            List <string> lstCellParameters = new List <string>();
            List <string> lstCellValues     = new List <string>();
            for (int a = 0; a < lstLeadsData.HeaderRow.Cells.Count; a++)
            {
                lstCellColumns.Add(lstdata[a]);
                lstCellParameters.Add("@" + lstdata[a]);
                lstCellValues.Add(gridRow.Cells[a].Text);
            }
            string columns = string.Join(",", lstCellColumns);
            string values  = string.Join(",", lstCellParameters);
            msSqlHelper.InsertData(txtConnectionString.Text, drpTables.SelectedItem.Text, columns, values, lstCellParameters, lstCellValues);
        }
    }