Click here to Skip to main content
12,358,777 members (61,604 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET SQL-Server
Dear Friends,

I have a Database with No.of Tables in it.

I have a one Table in it, which displays records into gridview.

I need to Insert Gridview Row to New Table in SqlServer 2005 database. when Select button Click in Gridview.....SELECT button will be Cell[0].

How to Insert the Selected Row From GRIDVIEW into Sqlserver 2005 Database New Table.


Please help me, Thanks.
Posted 19-Jun-12 22:30pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Check out the following code
protected void grdVacancy_SelectedIndexChanged(object sender, EventArgs e)
    {
       string query= "insert into tablename (columnname) values('"+ grdVacancy.SelectedRow.Cells[1].Text+"')";
    }
mark it solution if you got your answer and dont forget to rate..



Thanks
Ashish
  Permalink  
Comments
Member 11226864 20-Nov-14 6:06am
   
Not working
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow r = GridView1.SelectedRow;
        string strQuery = "insert into table values('" + r.Cells[0] + "','" + r.Cells[1] + "')";
    }

improved only for making in code
  Permalink  
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

write your insert query in selectedindexchange event of gridview.
  Permalink  
v2
Comments
Ranjith Reddy CSE 20-Jun-12 4:53am
   
Please can you show me, how to write.

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160621.1 | Last Updated 16 Oct 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100