Hi there,
So I have a web site that uses a main GridView with child GridView.
Using this very useful suggestion I want to a copy (clone) existing row and paste it back into the GridView.
Using my code below I obtain this error because the SProc that populates the child GridView don't find the expected parameter
Exception Details:
MySql.Data.MySqlClient.MySqlException: Incorrect integer value: '' for column 'tcustomerId' at row 1
at
cmd.Parameters.AddWithValue("tcustomerId", customerId);
Thanks for any advice.
protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.DataItem != null)
{
GridView gv_Child = (GridView)e.Row.FindControl("gv_Child");
if (gv_Child != null)
{
string customerId = gvProducts.DataKeys[e.Row.RowIndex].Value.ToString();
DataSet ds = new DataSet();
using (MySqlConnection cn =
new MySqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString))
{
using (MySqlCommand cmd =
new MySqlCommand("SProc", cn))
{
cmd.Connection.Open();
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("tcustomerId", customerId);
MySqlDataAdapter adapter = new MySqlDataAdapter();
adapter = new MySqlDataAdapter(cmd);
adapter.Fill(ds);
cmd.Connection.Close();
gv_Child.DataSource = ds.Tables[0];
gv_Child.DataBind();
}
}
}
}
}
}