store the value of datagrid to database

  • Thread starter Thiyagarajan Natarajan
  • Start date
T

Thiyagarajan Natarajan

Hi all!
I am getting the data from datagrid. and i have to store in database by
cliking the save button.

private void imgbtnSave_Click(object sender, System.Web.UI.
ImageClickEventArgs e)
{
StringBuilder sbQuery = new StringBuilder("");
sbQuery.Append("insert into CT_Customers(Module,subModule,Version)values")
foreach(DataGridItem dgi in this.dgModule.Items)
{
sbQuery.Append("'"+ dgi.Cells[1].Text.ToString().Trim().Replace("'","''")+"',
");
sbQuery.Append("'"+ dgi.Cells[2].Text.ToString().Trim().Replace("'","''")
+"',");
sbQuery.Append("'"+ dgi.Cells[3].Text.ToString().Trim().Replace("'","''")+"',
");
}
}
SQLHelper.ExecuteNonQuery(sbQuery.ToString());



but it doesn't go to even foreach loop while debugging.

can anybody help me please??
thanks all
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top