This is a migrated thread and some comments may be shown as answers.

[Solved] Button in RadGrid

2 Answers 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rick Rehorst
Top achievements
Rank 1
Rick Rehorst asked on 15 Nov 2009, 01:18 AM
Hi

I have a database with a company and a persons table. The person table has an FK to the CompanyID in the company table.
A person can be connected to a company (or not)
In my company grid, I have a separate grid (not a detailsgrid!) in a nested template
On expand, the template is shown and the connected persons grid is shown

For the persons grid on the nested template I have an ordinary RADGrid and I have a delete column and i replaced the text with an image. But for the delete function actualy I need to have two types of delete

option 1 deletes the complete person in the person table (normal delete function in the grid)
option 2 clears only the FK to the company and makes it a stand alone person, not connected to a company

I was considering a second delete column with a imagebutton which click event I can catch directly in VB code behind but I don't know how to.

Anyone an idea how to approach this?

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 16 Nov 2009, 07:21 AM
Hello Rick,

You can set the CommandName for the deletebuttoncolumn which will trigger the ItemCommand event on clicking the button. Here's an example:
aspx:
<telerik:GridButtonColumn UniqueName="DeleteColumn" ImageUrl="Images/DeleteImg.gif" 
 ButtonType="ImageButton" CommandName="DeleteFK" > 
</telerik:GridButtonColumn> 

c#:
Protected Sub RadGrid1_ItemCommand(source As Object, e As GridCommandEventArgs) 
    If e.CommandName = "DeleteFK" Then 
        Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem) 
           ' query to delete the FK
    End If 
End Sub   

Thanks
Princy.
0
Rick Rehorst
Top achievements
Rank 1
answered on 17 Nov 2009, 08:42 AM
Thanks

That worked perfectly..

Rick
Tags
Grid
Asked by
Rick Rehorst
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Rick Rehorst
Top achievements
Rank 1
Share this question
or