Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a gridview that contain more than 100 records, in itemtemplate i have ackeckbox for eah row. Here i want to insert all checked checkbox row to the database
XML
<asp:GridView ID="GridView1" runat="server" Width="96%" PageSize="10" OnSelectedIndexChanging="GridView1_SelectedIndexChanging" OnRowCommand="GridView1_RowCommand" >
                   <columns>
           <asp:TemplateField HeaderText="Select">
               <itemtemplate>
                   <asp:CheckBox ID="chkbox" runat="server">
               </itemtemplate>

                       <asp:TemplateField HeaderText="Remark">
               <itemtemplate>
                  <asp:Label ID="lblremark" runat="server">
               </itemtemplate>

           </columns>

the above is the source code i have.

Code behind
C#
    protected void btnview_Click(object sender, EventArgs e)
{
        GridView1.Visible = true;
        SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=TNVKP_8;Integrated Security=True");
        con.Open();
        DataSet reportData = new DataSet();
        //reportData.ReadXml(Server.MapPath("test.xml"));
        filename = System.IO.Path.GetExtension(FileUpload1.FileName.ToString());
        if (filename == ".xml")
        {
            reportData.ReadXml(Server.MapPath(FileUpload1.FileName));
            GridView1.DataSource = reportData;
            GridView1.DataBind();            
            con.Close();
        }
        else
        {
            GridView1.Visible = false;
            Response.Write("Invalid File");
        }
}

the above code i have used to view the xml data in the gridview now i want to insert the gridview data in to database. Post solution for this
Thanks in advance
Posted
Updated 4-Dec-11 18:44pm
v5
Comments
[no name] 5-Dec-11 0:45am    
EDIT: added "pre" tag

You can do the bulk insert in backend code. Reference at: http://msdn.microsoft.com/en-us/library/ms188365.aspx[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900