Last post Jun 21, 2013 02:21 PM by amlijupnandanan
Jun 21, 2013 01:26 PM|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 01:33 PM|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 01:36 PM|salwa.khan|LINK
no they are not. please check!
Jun 21, 2013 01:44 PM|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 02:19 PM|salwa.khan|LINK
Thanks! I was passing a wrong cell number
Jun 21, 2013 02:21 PM|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