I am trying to update a template in a gridview but it gaves me this error:
Unable to cast object of type 'System.Web.UI.WebControls.TextBox' to type 'System.IConvertible'.
Below is my code behind.
- int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
-
- int id = Convert.ToInt32(e.CommandArgument);
- string option = ((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox1")).Text;
- string day = ((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox2")).Text;
- decimal netpremium = Convert.ToDecimal(((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox3")));
- decimal vat = Convert.ToDecimal(((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox4")));
- decimal registry = Convert.ToDecimal(((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox5")));
- decimal totalpremium = Convert.ToDecimal(((TextBox)GridView1.Rows[rowIndex].FindControl("TextBox6")));
- TravelAssuranceDataAccess.UpdatePremium(id, option, day, netpremium, vat, registry, totalpremium);
- GridView1.EditIndex = -1;
- BindGridViewData();
Thanks in advance for any assistance.