I'm fairly new to Telerik so please bear with me.
I have two buttons: One does a SQL Insert and the other does a SQL Update, both work correctly as they currently are. The update button is currently hidden from the user. What I want to happen is if the user clicks the EditCommand link in the RadGrid, I want the Insert button to hide and the Update button to become visible. My question is - how do you interact with the EditCommand in C#?
5 Answers, 1 is accepted
Generally, you can use the ItemCommand event handler provided by RadGrid to catch the command actions:
An alternative approach would be:
Hope this helps. Please give it a try and let me know if it works for you.
I managed to get this to work by hiding the Insert button and showing the Update button from within my ItemCommand event handler. I had to make some changes my SQL query and it led me to creating a UpdateCommand event. Currently I'm not sure how to call that event in my button click. How do I make that call?
Here is my code for the UpdateCommand:
Here is the event for my button click:
You could initiate the UpdateCommand by calling the MasterTableView's PerformUpdate method, which accepts a GridEditableItem:
However, although that it is not clear enough if your buttons are placed within the rows or outside the grid, if they are placed within the items you can set the CommandName property of the buttons, which will automatically initiate the update/insert:
The above is a simple example from our EditForm Template demo.
If any other questions arise, please elaborate on your exact scenario.
For a scenario where your button is outside the grid, you should use the first suggestion from my previous post, where could call the PerformUpdate method for the GridEditableItems that you want to update.