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

[Solved] RadGrid GridButtonColumn in Type of Image not firing ItemCommand

3 Answers 312 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mohamed
Top achievements
Rank 1
Mohamed asked on 13 Jun 2012, 12:42 AM
button of ButtonType="ImageButton" not firing the item command, even if the button type changed to anything else it works.
Here is my code..
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
        AllowCustomPaging="True"
        GridLines="None" onitemcommand="RadGrid1_ItemCommand"
        ShowGroupPanel="True" Skin="Black">
    <MasterTableView>
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
        <Columns>
            <telerik:GridButtonColumn UniqueName="btnDelete" CommandName="CommandDelete"   ButtonType="ImageButton" ImageUrl="~/Styles/images/DeleteRed.png" />
         
        </Columns>
 
        <PagerStyle AlwaysVisible="true" />
 
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
    </MasterTableView>
 
    <ClientSettings EnableRowHoverStyle="false" AllowDragToGroup="True">
<Selecting CellSelectionMode="None"></Selecting>
    </ClientSettings>                   
 
    <PagerStyle AlwaysVisible="True" />
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
</telerik:RadGrid>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 13 Jun 2012, 06:50 AM
Hi Mohamed,

I tried the same scenario and its working fine at my end.Please take a look into the following code snippet.

ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" AllowCustomPaging="True" GridLines="None" ShowGroupPanel="True" Skin="Black" onitemcommand="RadGrid1_ItemCommand" onneeddatasource="RadGrid1_NeedDataSource">
    <MasterTableView>
        <Columns>
            <telerik:GridButtonColumn UniqueName="btnDelete" CommandName="CommandDelete"   ButtonType="ImageButton" ImageUrl="~/Styles/images/DeleteRed.png" /> 
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "CommandDelete")
    {
        //your code
    }
}

Please provide the code behind if it doesn't help.

Thanks,
Princy.
0
Jay
Top achievements
Rank 2
answered on 12 Apr 2013, 10:13 AM
<telerik:RadGrid ID="radGridDocument" runat="server" Width="100%" AllowFilteringByColumn="True" AllowPaging="True"
                                 Font-Size="11px" AllowMultiRowSelection="true" AllowSorting="True" GridLines="Vertical" AutoGenerateColumns="false" CellPadding="0" OnInit="radGridDocument_Init" OnItemDataBound="radGridDocument_ItemDataBound" >


I wired-up the Item-Command in the Page Load:

radGridDocument.ItemCommand += new GridCommandEventHandler(radGridDocument_ItemCommand);


here's my ItemCommand method that is not firing:

protected void radGridDocument_ItemCommand(object sender, GridCommandEventArgs e)
{
    if (e.CommandName == ClientDocumentManagement.DocNameColumn)
    {
         
        //SaveSessionData(e.Item);
 
        Response.Redirect(DocumentManagementFiles.URL);
    }
}


Why is that my ItemCommand method is not firing? Thanks.

0
Princy
Top achievements
Rank 2
answered on 25 Apr 2013, 11:17 AM
Hi,

Unfortunately I couldn't replicate the issue at my end. Here is the complete code snippet I tried with your mark-up.

ASPX:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" AutoGenerateColumns="False"
    AllowCustomPaging="True" GridLines="None" ShowGroupPanel="True" Skin="Black">
    <MasterTableView>
        <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
        <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
        </RowIndicatorColumn>
        <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridButtonColumn UniqueName="btnDelete" CommandName="CommandDelete" ButtonType="ImageButton"
                ImageUrl="~/Images/editServerButton.gif" />
        </Columns>
        <PagerStyle AlwaysVisible="true" />
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <ClientSettings EnableRowHoverStyle="false" AllowDragToGroup="True">
        <Selecting CellSelectionMode="None"></Selecting>
    </ClientSettings>
    <PagerStyle AlwaysVisible="True" />
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
</telerik:RadGrid>

C#:
protected void RadGrid1_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (e.CommandName == "CommandDelete")
    {
 
    }
}

Thanks,
Princy.
Tags
Grid
Asked by
Mohamed
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jay
Top achievements
Rank 2
Share this question
or