Link to home
Start Free TrialLog in
Avatar of exploit344
exploit344

asked on

insert gridview values into database

i wanna save gridview values to database..
my gridview contains nothing i mean no textbox ,label..

the code i am using it saves the values but save like.."System.Web.UI.WebControls.GridViewRowCollection" in database column...

now how do i save gridview rows
foreach(GridViewRow row in GridView1.Rows)
        {
            if(row.RowType==DataControlRowType.DataRow)
            {
                cmd = new SqlCommand("insert into t1(first,second)values(@first,@second)", con);
                cmd.Parameters.AddWithValue("@first",GridView1.Rows[0].ToString());
                cmd.Parameters.AddWithValue("@second", GridView1.Rows[1].ToString());
                cmd.ExecuteNonQuery();
            }
        }

Open in new window

2.jpg
ASKER CERTIFIED SOLUTION
Avatar of mahajan344
mahajan344

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of exploit344
exploit344

ASKER

thnx a lot dude its working fine...