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

RadGrid not firing postback on ItemCommand events

2 Answers 389 Views
Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
nanthakumar thangavel
Top achievements
Rank 1
nanthakumar thangavel asked on 13 Aug 2010, 06:39 PM

Hi,

I'm currently evaluating some RAD controls from Telerik, just right now I'm experimenting with the RadGrid.

So I have my grid control and enabled client-side binding for having Ajax support. I created an appropriate WCF webservice for fetching the data etc. Everything works really good, including paging etc. Now I wanted to have a button column for deleting some items. I registered the OnItemCommand event of the grid and implemented it accordingly on the server-side. My ASPx code looks like this:

<telerik:RadGrid runat="server" ID="RadGrid1" AllowPaging="True" AllowSorting="True"
    AutoGenerateColumns="False" GridLines="None"
    OnItemCommand="RadGrid1_ItemCommand">
    <MasterTableView DataKeyNames="Id" ClientDataKeyNames="Id">
        <Columns>
            <telerik:GridBoundColumn DataField="Firstname" HeaderText="Firstname" DataType="System.String">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Lastname" HeaderText="Lastname" DataType="System.String">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Age" HeaderText="Age" DataType="System.Int32">
            </telerik:GridBoundColumn>
            <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="DeleteColumn"
                ButtonType="ImageButton">
            </telerik:GridButtonColumn>
        </Columns>
        <PagerStyle Mode="Slider" />
    </MasterTableView>
    <ClientSettings>
        <DataBinding SelectMethod="GetSampleData" Location="Webservice/GridData.svc" SortParameterType="String">
        </DataBinding>
    </ClientSettings>
</telerik:RadGrid>

However when clicking on the appropriate button on a grid row the event isn't fired, basically no postback to the server is being done. A solution I found is to add the "EnablePostBackOnRowClick=true" to the ClientSettings, but this would cause a postback on each click on a row, which is not really desired.

Is there a better way to realizing this or does anybody have a hint what could be the problem??

2 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 18 Aug 2010, 04:18 PM
Hello,

As you populate your RadGrid using client-side binding, my suggestion is that you delete the record by attaching a handler to grid's OnCommand client event and checking for the commandname whether it is delete or not. If the commandname is delete, then delete the row from RadGrid by calling the webservice method to delete as shown in this online demo.

Kind regards,
Tsvetina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
nanthakumar thangavel
Top achievements
Rank 1
answered on 19 Aug 2010, 05:33 AM
hi 

Thank you very much...
Tags
Visual Style Builder
Asked by
nanthakumar thangavel
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
nanthakumar thangavel
Top achievements
Rank 1
Share this question
or