locked
On Button Click Event RRS feed

  • Question

  • User-1212847090 posted

    So I have this code in the code behind

    protected void b1_OnClick(object sender, EventArgs e)
    {
    SqlDataSource1.UpdateCommand = "UPDATE [tbl_shiporders] SET [Truck]=@TruckTo WHERE [Truck]=@TruckFrom AND [branch_id]=@ddlBranch AND [LoadDate]=Date()";

    SqlDataSource1.Update();

    grid1_Rebinding();
    }

    And this on the web page

    <asp:Button id="b1" Text="Execute" runat="server" />


    But it's doing nothing, I've played around with the WHERE query to see if it had anything to do with me not writing in any update parameters but it still didn't execute

    I don't see anything wrong with it? Can you?

    Thanks In advance

    Friday, October 23, 2015 10:28 PM

Answers

  • User2103319870 posted

    But it's doing nothing, I've played around with the WHERE query to see if it had anything to do with me not writing in any update parameters but it still didn't execute

    I don't see anything wrong with it? Can you?

    You need to attach the click event handler to the button. Try with the below code

            <asp:Button id="b1" Text="Execute" runat="server"  OnClick="b1_OnClick"/>
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 23, 2015 11:25 PM

All replies

  • User2103319870 posted

    But it's doing nothing, I've played around with the WHERE query to see if it had anything to do with me not writing in any update parameters but it still didn't execute

    I don't see anything wrong with it? Can you?

    You need to attach the click event handler to the button. Try with the below code

            <asp:Button id="b1" Text="Execute" runat="server"  OnClick="b1_OnClick"/>
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 23, 2015 11:25 PM
  • User-1212847090 posted

    Oh my god, simples! My excuse first thing in the morning, Thank You buddy!

    Friday, October 23, 2015 11:30 PM
  • User2103319870 posted

    Glad to be of help

    Friday, October 23, 2015 11:39 PM