Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

i have a Gridview which is connected with SqlDataSource for Data.
I have Edit and Delete built in functionality. I have passed the Stored Procedure for the SelectCommand.

Now i want to delete record and simultaneously update another table, now i do not get how to pass the values for the delete parameters in DeleteCommand

I also added DataKeyNames wherein i have provided the field (which is Primary Key and Auto Increement), but that too does not works. While deleting it simply says, Deleting is Supported, because no DeleteCommand is Specified.

I also tried creating a StoredProcedure for the delete task, but my StoredProcedure need to have some parameters so that i can update the records in another table.

can anyone tell how could i pass the value for the Delete paremeter.

UPDATED with SqlDataSource Markup

<asp:SqlDataSource ID="StudAllotmentDataSource" runat="server" 
    ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" 
    SelectCommand="user_GetStudAllotment" SelectCommandType="StoredProcedure" DeleteCommand="user_DeleteAllottedStudBook" DeleteCommandType="StoredProcedure">
   <DeleteParameters>
        <asp:Parameter Name="BookCode" Type="String" /> 
        <asp:Parameter Name="Quantity" Type="String" /> 
    </DeleteParameters>
</asp:SqlDataSource>
share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Did you specify DeleteCommand as your stored procedure in the sqlserverdatasource?

share|improve this answer
 
yes i have, but that requires 2 parameters, which i need, to utilize for updating records in another table –  Abbas Dec 31 '12 at 6:32
 
can you post the markup of your sqldatasource? –  Pawan Nogariya Dec 31 '12 at 6:41
 
i have updated the question with the sqldatasource markup –  Abbas Dec 31 '12 at 6:45
 
you are using the same datakeynames in your stored procedure, right? I mean something like ... where BookCode = '@BookCode' and Quantity = '@Quantity' and quantity is your data key? –  Pawan Nogariya Dec 31 '12 at 6:51
 
I had to put single quotes on the parameters like this '@Quantity' because I could not make comment with this directly @Quantity, so understand my code accordingly –  Pawan Nogariya Dec 31 '12 at 6:52
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.