Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to pass value using ImageButton to update database?
    primarykey
    data
    text
    <p>I having problem when I try to pass value from ImageButton to a controlparameter, then the update command can retrieve the value from control parameter to execute update statement.</p> <p>I want to pass value Status=1 when ImageButton APPROVE is clicked, else pass value Status=2 when ImageButton REJECT is clicked.</p> <p>Where and how should I assign value Status? When I run my code, I receive this error : Must declare the scalar variable "@Status".</p> <p>Or any recommendation to pass the value Status?</p> <p>My ImageButton:</p> <pre><code>&lt;ItemTemplate&gt; &lt;asp:ImageButton runat="server" ID="APPROVE" CommandName="update" ImageUrl="~/images/accept.png" OnClientClick="if (!window.confirm('Are you sure you want to approve this booking?')) return false;" /&gt; &lt;/ItemTemplate&gt; &lt;ItemTemplate&gt; &lt;asp:ImageButton runat="server" ID="REJECT" CommandName="update" ImageUrl="~/images/reject.png" OnClientClick="if (!window.confirm('Are you sure you want to reject this booking?')) return false;" /&gt; &lt;/ItemTemplate&gt; </code></pre> <p>My UPDATE statement</p> <pre><code>UpdateCommand="UPDATE [bookingschedule] SET status=@Status WHERE [bookingScheduleID] = @bookingScheduleID" </code></pre> <p>My ControlParameter</p> <pre><code>&lt;UpdateParameters&gt; &lt;asp:Parameter Name="bookingScheduleID" Type="Int32" /&gt; &lt;asp:ControlParameter Name="Status" ControlID="APPROVE" Type="Int32" /&gt; &lt;asp:ControlParameter Name="Status" ControlID="REJECT" Type="Int32" /&gt; &lt;/UpdateParameters&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload