hi this is my update property code in gridview
protected void UpdateCustomer(object sender, GridViewUpdateEventArgs e)
{
string CustomerID = ((Label)GridView1.Rows[e.RowIndex].FindControl("lblCustomerID")).Text;
string Name = ((TextBox)GridView1.Rows[e.RowIndex].FindControl("txtContactName")).Text;
SqlCommand cmd = new SqlCommand("classmanagerup", _cn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@ID", SqlDbType.VarChar).Value = CustomerID;
cmd.Parameters.Add("@Classification", SqlDbType.VarChar).Value = Name;
GridView1.EditIndex = -1;
GridView1.DataSource = GetData(cmd);
GridView1.DataBind();
}
private
DataTable GetData(SqlCommand cmd)
{
DataTable dt =
new
DataTable();
SqlDataAdapter sda =
new
SqlDataAdapter();
cmd.CommandType = CommandType.Text;
cmd.Connection = _cn;
_cn.Open();
sda.SelectCommand = cmd;
sda.Fill(dt);
return
dt;
}
and this is my StoreProcedure
ALTER procedure [dbo].[classmanagerup]
@ID smallint,
@Classification nvarchar(50)
as
begin
update House_p set Classification=@Classification
where ID=@ID
select distinct ID, classification,Totalproduct
from House_p
where BehCode=1116
end
when i run website this error occur
Procedure or function 'classmanagerup' expects parameter '@ID', which was not supplied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Procedure or function 'classmanagerup' expects parameter '@ID', which was not supplied.
Source Error:
Line 152: _cn.Open();
Line 153: sda.SelectCommand = cmd;
Line 154: sda.Fill(dt); Line 155: return dt;
Line 156: }
|
i have @ID in SP why this error occur?
best regards