Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
1
Reply
Unable to cast object of type 'System.Web.UI.WebControls.Tex
Hold On
Oct 4 2017 3:49 AM
136
Reply
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.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
how to print 2 / 6 label in crystal report
How to add/remove columns at runtime in KendoGrid