Click here to Skip to main content
15,889,659 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hello, i'm beginner for here, i just try to basic DML concept in gridview but i got error but i dont know how to clear this please help me....

My .cs code here....
C#
public void gedata()
{
    connection();
    HiddenField1.Value = "view";
    query = "DMLgrid_SP";
    com = new SqlCommand(query, con);
    com.CommandType = CommandType.StoredProcedure;
    com.Parameters.AddWithValue("@Action", HiddenField1.Value).ToString();
    SqlDataAdapter da = new SqlDataAdapter(com);
    DataSet ds = new DataSet();
    da.Fill(ds);
    GridView1.DataSource = ds;
    GridView1.DataBind();
    con.Close();
}


please tell me when i want to add parameter id
Posted
v4

1 solution

The error message is quite clear.

That means the StoredProcedure "DMLgrid_SP" is expecting parameter @id, but you are not sending that from code.

So, do something like below to send the parameter.
C#
com.Parameters.AddWithValue("@id", someID);


Also no need call ToString() here.
com.Parameters.AddWithValue("@Action", HiddenField1.Value).ToString();
 
Share this answer
 
Comments
♥…ЯҠ…♥ 16-Dec-13 1:43am    
Crystal shot.... deserves 5+ ;)
Thanks a lot ♥…ЯҠ…♥... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900