Search code examples
c#.nettelerikradgrid

.net Radgrid with button in column only fires itemcommand on 2nd click


I'm having an issue where the button within a radgrid is not firing until second time.

I have a usercontrol with a radgrid on it and button within one of its column. The usercontrol is placed on a page.

When clicking the button on radgrid nothing happens 1st time, however it works 2nd time.

This is some of the radgrid column data

<telerik:GridTemplateColumn DataField="Quantity" HeaderText="Quantity" UniqueName="QuantityCol">
        <ItemTemplate>
            <asp:TextBox ID="Quantity" runat="server" Columns="4" Text='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' width="40px" />                
                 <asp:LinkButton id='btnUpdateRow' runat="server" CausesValidation="false" Text='<span>Update</span>' CommandName="ButtonUpdateRow"  CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>'/>                 
        </ItemTemplate>
    </telerik:GridTemplateColumn>

The radgrid uses NeedDataSource to obtain its data. Page Load does not do anything.

During debug within itemcreated/itemdatabound, the linkbutton clientid it shows

TestBasket_RadGrid1_ctl01_ctl04_btnUpdateRow

However, when rendered to the browser it shows as

<a id="TestBasket_RadGrid1_ctl01_ctl09_btnUpdateRow" href="javascript:__doPostBack('TestBasket$RadGrid1$ctl01$ctl09$btnUpdateRow','')">

Clicking the button - itemcommand is NOT fired. On returning from postback the brower shows

<a id="TestBasket_RadGrid1_ctl01_ctl04_btnUpdateRow" href="javascript:__doPostBack('TestBasket$RadGrid1$ctl01$ctl04$btnUpdateRow','')">

Clicking the button - itemcommand is fired.

Anyone explain why clientid gets changed. I have tried placing a placeholder and creating the control with an id in itemcreated - still same issue.

Thanks in advance for any help.


Solution

  • Looks like the issue happened because of page inheritance. I made a simple aspx page not using any of our architecture and it seemed to work fine. I then bought the code back in and it stopped working. I’ve managed to fix it by changing the page inheritance of the pages that use Telerik controls.