Last post Jun 21, 2013 09:21 AM by amlijupnandanan
Jun 21, 2013 08:26 AM|salwa.khan|LINK
I'm a beginner in asp.net c#. I'm trying to insert values of a gridview into the database calling a stored procedure.
am getting an error "input string not in correct format". please anybody correct where am I wrong
here is my stored procedure
ALTER proc [dbo].[sp_insertIntoAssessedProposals]
@Title as varchar(50),
@GrantAmount as int,
@ApprovedAmount as int,
@ProposalID as int
insert into dbo.tbl_AssessedProposals
and the c# code is like this:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
GridViewRow r = GridView1.SelectedRow;
if (e.CommandName.ToString() == "Approve")
TextBox tb = (TextBox)r.FindControl("TextBox1");
string txt = tb.Text;
tbl_AssessedProposalsTableAdapter ta = new tbl_AssessedProposalsTableAdapter();
Jun 21, 2013 08:33 AM|Vijay Patel|LINK
check your r.Cells.Text values, it might be empty or null thats why you are getting this error.
Jun 21, 2013 08:36 AM|salwa.khan|LINK
no they are not. please check!
Jun 21, 2013 08:44 AM|shailendra3009|LINK
might be you are passing wrong value in last parameter, may be you have passed wrong cell number....
as per my interpretation it would be title value which you are passing in first parameter as well in last one... so pass proposalid cell number in last argument
try it by change cell number...
Jun 21, 2013 09:19 AM|salwa.khan|LINK
Thanks! I was passing a wrong cell number
Jun 21, 2013 09:21 AM|amlijupnandanan|LINK
Pls check the data u send to stored procedure...
May be u send integer value in place of varchar field..
or give the table structure and the data in which u send to the stored procedure