hi
i am using below code to store gridview data to database
but storing empty values
try
{
foreach (GridViewRow g1 in GridView1.Rows)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["connstring"].ToString());
Response.Write(g1.Cells[1].Text);
SqlCommand com = new SqlCommand("insert into orderproduct(id,name,price,qty,total) values ('" + g1.Cells[0].Text + "','" + g1.Cells[1].Text + "','" + g1.Cells[2].Text + "','" + g1.Cells[3].Text + "','" + g1.Cells[4].Text + "')", con);
con.Open();
com.ExecuteNonQuery();
con.Close();
lblerror.Text = "Successs";
}
}
catch (Exception ex)
{
lblerror.Text = ex.Message;
}
asp:TemplateField HeaderText=" Price" HeaderStyle-CssClass ="headercen">
<ItemTemplate>
<table><tr> <td> <%# Eval("rate") %></td><br /></tr> </table>
</ItemTemplate>
<ItemStyle BorderStyle="None" HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:TemplateField>