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

Issue with OnItemCommand firing when clicking on attachment column link

1 Answer 18 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Laurie
Top achievements
Rank 1
Laurie asked on 14 Jun 2013, 07:39 PM
I'm using entity framework btw.  I'm just trying to get the itemcommand method to fire at this point. 

CS code:

 

protected void grdFiles_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == RadGrid.DownloadAttachmentCommandName)
    {
        using (var db = new isoAuditModelContainer())
        
        RadAjaxManager Manager = new RadAjaxManager();
        Manager.EnableAJAX = false;
        GridDownloadAttachmentCommandEventArgs args = e as GridDownloadAttachmentCommandEventArgs;
        string fileName = args.FileName;
        int attachmentId = (int)args.AttachmentKeyValues["procedure_document"];
        var query = (from x in db.procedures where x.Id == 1 select x).First();
        byte[] binaryData = (byte[])query.procedure_document;
        Response.Clear();
        Response.ContentType = "application/octet-stream";
        Response.AddHeader("content-disposition", "attachment; filename=" + fileName);
        Response.BinaryWrite(binaryData);
        //Response.OutputStream.Write(binaryData, 0, binaryData.Length);
        Response.Flush();
        Response.Close();
        Response.End();
          
        }
    }
}


ASPX Code:


         <telerik:RadGrid ID="grdStandards" runat="server" Width="730px" AutoGenerateColumns="False"
            OnNeedDataSource="grdStandards_NeedDataSource" CellSpacing="0" 
                GridLines="None" OnItemComand="grdFiles_ItemCommand">
  
            <MasterTableView AllowMultiColumnSorting="True" DataKeyNames="">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
  
<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
  
<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                <Columns>
  
                    <telerik:GridBoundColumn DataField="name" 
                        FilterControlAltText="Filter column column" HeaderText="Name" 
                        UniqueName="column">
                    </telerik:GridBoundColumn>
                    <telerik:GridAttachmentColumn FileName="attachment" 
                        FilterControlAltText="Filter procedure_document column" HeaderText="Procedures" 
                        UniqueName="procedure_document" 
                        AttachmentDataField="procedure_document" 
                        AttachmentKeyFields="procedure_document,Id,name,comments" 
                        Text="View Procedure">
                    </telerik:GridAttachmentColumn>
  
                </Columns>
  
<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
            </MasterTableView>
  
<FilterMenu EnableImageSprites="False"></FilterMenu>
            </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 1
answered on 17 Jun 2013, 04:05 AM
Hi,
This may look very silly but your item command is as this:
OnItemComand="grdFiles_ItemCommand"
The spelling of Command is wrong,Please try setting it right,when i did that its firing.Rest everything is working fine on my side.
              OnItemCommand="grdFiles_ItemCommand"    

Thanks
Princy
Tags
Grid
Asked by
Laurie
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 1
Share this question
or