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

Command Item

1 Answer 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
padmanaban
Top achievements
Rank 1
padmanaban asked on 23 Mar 2011, 10:28 AM
Below is my code. my query is if i use Button type as LinkButton, i got the result. But the type is Image/push button then the back-end code doesn't work. whats the problem in this? can any one help?


    <telerik:RadGrid ID="RadGrid1" runat="server" Width="100%" GridLines="None"
            AutoGenerateColumns="False" PageSize="13" AllowSorting="True" AllowPaging="True"
            ShowStatusBar="True" >
            <MasterTableView DataKeyNames="Cid" AllowMultiColumnSorting="True" Width="100%"
                CommandItemDisplay="None">
                <Columns>
                    <telerik:GridBoundColumn UniqueName="Cid" SortExpression="Cid" HeaderText="Cid"
                        DataField="Cid" Visible="false" />
                    <telerik:GridDateTimeColumn UniqueName="HolidayDate" SortExpression="HolidayDate" HeaderText="Date"
                        DataField="HolidayDate" DataFormatString="{0:d}" />
                    <telerik:GridBoundColumn UniqueName="HolidayFor" SortExpression="HolidayFor" HeaderText="Holiday name"
                        DataField="HolidayFor" />
                    <telerik:GridButtonColumn UniqueName="EditColumn" CommandName="Edit" ButtonType="ImageButton" 
                        HeaderText ="Action" Text="Edit" HeaderStyle-Width="20px" />
                    <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" ButtonType="LinkButton" 
                        Text="Delete"  HeaderStyle-Width="20px"/>
                </Columns>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents />
            </ClientSettings>
        </telerik:RadGrid>

    Protected Sub RadGrid1_DeleteCommand(ByVal source As Object, ByVal e As GridCommandEventArgs) Handles RadGrid1.DeleteCommand
        Dim ID As String = (CType(e.Item, GridDataItem)).OwnerTableView.DataKeyValues(e.Item.ItemIndex)("Cid").ToString
        If e.CommandName = "Delete" Then
            Response.Write(ID)
end if
    End Sub

1 Answer, 1 is accepted

Sort by
0
Accepted
Pavlina
Telerik team
answered on 23 Mar 2011, 10:46 AM
Hello,

Can you please verify that you are not calling a DataBind() method inside the PageLoad event? If this is the case try removing DataBind() from your code and see whether the DeleteCommand is getting fired. 

You can also refer the following forum link which discusses a similar issue.
GridButtonColumn and OnDeleteCommand

Kind regards,
Pavlina
the Telerik team
Tags
Grid
Asked by
padmanaban
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Share this question
or