ItemCommand not getting fired.

4 posts, 0 answers
  1. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 12 Jan 2010 Link to this post

    Hello,

    Here is my grid.

    <Telerik:RadGrid ID="gridLists" runat="server" AutoGenerateColumns="False" GridLines="None" AllowAutomaticDeletes="false" AllowAutomaticInserts="false" AllowAutomaticUpdates="false">  
                    <MasterTableView>  
                        <Columns>  
                            .  
                            .  
                            .  
                            .  
                            .  
                            <Telerik:GridButtonColumn HeaderText="Edit" CommandName="ListEdit" Text="Edit" UniqueName="EditColumn"></telerik:GridButtonColumn>  
                            <Telerik:GridButtonColumn HeaderText="Delete" CommandName="ListDelete" Text="Delete" UniqueName="DeteleColumn"></telerik:GridButtonColumn>  
                        </Columns>  
                        <NoRecordsTemplate>You have not selected any lists.</NoRecordsTemplate>  
                          
                    </MasterTableView>  
                    </Telerik:RadGrid> 


    As you can see i've two button columns to perform my custom operations.

    First i added the event handler in the codebehind like this.

    gridLists.ItemCommand +=new GridCommandEventHandler(gridLists_ItemCommand);

    But the event dint get fired. So i removed the line from the code behind and added this in the aspx to the grid.

    OnItemCommand="gridLists_ItemCommand" 

    Now i get the following error.

    "c:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\MPP.CalendarPro\Pages\MPP.CalendarPro.Settings.aspx(498): error CS0117: 'ASP._layouts_mpp_calendarpro_pages_mpp_calendarpro_settings_aspx' does not contain a definition for 'gridLists_ItemCommand'   at System.Web.Compilation.AssemblyBuilder.Compile() ...."

    Note : I'm working in the SharePoint environment.

    So what's the problem? Any ideas?

  2. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 12 Jan 2010 Link to this post

    Okie, dont laugh at me. I missed the "protected" access specifier in front of event function. Now i changed to this

    protected void gridLists_ItemCommand(object source, GridCommandEventArgs e) 

    and the error is gone. But still the event is not getting fired.

    Thanks.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 12 Jan 2010 Link to this post

    I went through this thread and added NeedDataSource event like this.

    OnNeedDataSource="gridLists_NeedDataSource" 


    protected void gridLists_NeedDataSource(object source, GridNeedDataSourceEventArgs e) 
            { 
                gridLists.DataSource = CreateListsDataTable(); 
            } 

    I tried debugging it and the NeedDataSource event got fired perfectly. But still the ItemCommand event is not getting fired for me.

    Thank you.
  5. NLV
    NLV avatar
    87 posts
    Member since:
    Aug 2009

    Posted 12 Jan 2010 Link to this post

    Okie, i fixed the issue. I was calling a grid Rebind() in OnInit() which was rebinding the grid and cancelling the event.

    Thank you.
Back to Top