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

ItemCommand not getting fired.

3 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
NLV
Top achievements
Rank 1
NLV asked on 12 Jan 2010, 10:23 AM
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?

3 Answers, 1 is accepted

Sort by
0
NLV
Top achievements
Rank 1
answered on 12 Jan 2010, 10:30 AM
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.
0
NLV
Top achievements
Rank 1
answered on 12 Jan 2010, 10:46 AM
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.
0
NLV
Top achievements
Rank 1
answered on 12 Jan 2010, 11:52 AM
Okie, i fixed the issue. I was calling a grid Rebind() in OnInit() which was rebinding the grid and cancelling the event.

Thank you.
Tags
Grid
Asked by
NLV
Top achievements
Rank 1
Answers by
NLV
Top achievements
Rank 1
Share this question
or