I’m using a FormView and binding it to a SqlDataSource using a stored procedure to edit a record. The thing is that after updating the record I need to call another function, which I’m doing using the onClick attribute of the button.
This function has to insert a few records into another table, using the ID of the record edited in the FormView. I know how to use SCOPE_IDENTITY when in the same stored procedure, but this time I need some logic that is easier to accomplish in the code-behind, but I don’t know how to obtain the ID, so any leads would be great.
Here is the button:
<asp:Button ID="EditButton" runat="server" CausesValidation="True" CommandName="Update"
Text="Edit" OnClick="setProcessProgress" />
And here is a stripped down version of the code behind:
protected void setProcessProgress(object sender, EventArgs e)
{
int ID_p;
ID_p = ; //TODO: Here I need to obtain the ID of the last edited record from the EditButton
setProgress(ID_p);
}
The stored procedure is a simple UPDATE statement.
I’m thinking of passing a parameter to the code behind, but not sure how to, perhaps something like this OnClick="setProcessProgress(@id)"
try like this, and you need to attach
OnCommand="CommandEventHandler"event handler to your button . check for More Info Button.Commandand the code for to get the ID