why a commandbutton give error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neoupadhyay
    New Member
    • Feb 2007
    • 57

    why a commandbutton give error

    'Investor.cmdSa veEduCost' is a 'field' but is used like a 'method'

    the HTML code is...
    <asp:Button ID="cmdSaveEduC ost" runat="server" Text="Save" OnClick = "cmdSaveEduCost " />

    and the C# code is as folow...
    protected void cmdSaveEduCost_ Click(object sender, EventArgs e)
    {
    string connectionStrin g = ConfigurationMa nager.Connectio nStrings["sqlFWA"].ConnectionStri ng;
    SqlConnection conn = new SqlConnection(c onnectionString );
    SqlCommand command = new SqlCommand();

    //command.Paramet ers.AddWithValu e("@Investor_ID ", Session["sInvestor_ ID"]);
    command.Paramet ers.AddWithValu e("@ItemDescrip tion", ItemDescription .Text);
    command.Paramet ers.Add("@Annua lCost", SqlDbType.Money ).Value = AnnualCost.Text ;
    command.Paramet ers.AddWithValu e("@CPIChildCos t", CPIChildCost.Te xt);
    command.Paramet ers.AddWithValu e("@ChildCostIt emTotal", ChildCostItemTo tal.Text);

    command.Command Type = CommandType.Sto redProcedure;
    command.Command Text =("[dbo].[NavinInsertComm and]");
    command.Connect ion = conn;
    conn.Open();
    command.Execute NonQuery();

    grdEduChild.Dat aBind();
    conn.Close();
    ItemDescription .Text = "";
    AnnualCost.Text = "";
    CPIChildCost.Te xt = "";
    ChildCostItemTo tal.Text = "";
    }
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    You appear to have a slip up.
    THIS:
    <asp:Button ID="cmdSaveEduC ost" runat="server" Text="Save" OnClick = "cmdSaveEduCost " />

    SHOULD BE:
    <asp:Button ID="cmdSaveEduC ost" runat="server" Text="Save" OnClick = "cmdSaveEduCost _Click" />

    Comment

    Working...