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

[Solved] GridAttachmentColumn with EntityDataSource

3 Answers 120 Views
Grid
This is a migrated thread and some comments may be shown as answers.
asimptota
Top achievements
Rank 1
asimptota asked on 25 Feb 2013, 01:07 PM
I need to implement RadGrid with GridAttachmentColumn that is using EntityDataSource. Database schema is like: DocumentID (PK, int), DocumentName(varchar(50)), DocumentDescription(varchar(255)), DocumentData(varbinary(max)). Now, is there an example apart from THIS one, that describes how to use GridAttachmentColumn? I was following this example and unfortunately couldn't get it to work. It seems a bit confusing. Is it possible to use one entity datasource for both file info and file binary data? Means, is it possible to use only one EntityDataSource for CRUD operations with table definition given above?

Thanx

3 Answers, 1 is accepted

Sort by
0
asimptota
Top achievements
Rank 1
answered on 26 Feb 2013, 07:26 AM
Anyone? Please.
0
Maria Ilieva
Telerik team
answered on 28 Feb 2013, 11:18 AM
Hello Jasmin,

You could set your RadGrid like this:
<telerik:RadGrid AutoGenerateColumns="False" AutoGenerateDeleteColumn="True" AutoGenerateEditColumn="True"
       DataSourceID="EntityAttachmentsDataSource" ID="EntityAttachmentsGrid"  runat="server">
       <MasterTableView DataKeyNames="Id" DataSourceID="EntityAttachmentsDataSource">
           <Columns>
               <telerik:GridBoundColumn DataField="Id" DataType="System.Int32" HeaderText="Id" ReadOnly="True"
                   UniqueName="Id">
               </telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="FileName" HeaderText="FileName" UniqueName="FileName"
                   ReadOnly="true" DataType="System.String">
               </telerik:GridBoundColumn>
               <telerik:GridAttachmentColumn DataSourceID="EntityAttachmentDataSource" MaxFileSize="1048576"
                   EditFormHeaderTextFormat="Upload Attachment:" HeaderText="Attachment" HeaderTooltip="Download Entity Attachment"
                   AttachmentDataField="Attachment" AttachmentKeyFields="Id" FileNameTextField="FileName"
                   DataTextField="FileName" UniqueName="InfringmentAttachment">
               </telerik:GridAttachmentColumn>
           </Columns>
       </MasterTableView>
       <ClientSettings>
           <ClientEvents OnCommand="GridOnCommand" />
       </ClientSettings>
   </telerik:RadGrid>
   <asp:EntityDataSource ConnectionString="name=MyEntities" DefaultContainerName="MyEntities"
       EnableFlattening="False" EntitySetName="EntityAttachments" EntityTypeFilter="EntityAttachment"
       ID="EntityAttachmentsDataSource" runat="server">
   </asp:EntityDataSource>
   <asp:EntityDataSource ConnectionString="name=MyEntities" DefaultContainerName="MyEntities"
       EnableFlattening="False" EntitySetName="EntityAttachments" EntityTypeFilter="EntityAttachment"
       ID="EntityAttachmentDataSource" runat="server" Where="it.[Id] = @Id" Select="it.[Attachment]">
       <SelectParameters>
           <asp:Parameter Name="Id" Type="Int32" />
       </SelectParameters>
   </asp:EntityDataSource>

I hope this helps.

Greetings,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
asimptota
Top achievements
Rank 1
answered on 28 Feb 2013, 11:23 AM
Thank you for your answer :)
In the meantime I've managed to make it work with EntityDataSource. But now I have different problem. I've opened another thread for this issue here: http://www.telerik.com/community/forums/aspnet-ajax/grid/gridattachmentcolumn-with-editmode-inplace.aspx
Could you help me with this one?
Tags
Grid
Asked by
asimptota
Top achievements
Rank 1
Answers by
asimptota
Top achievements
Rank 1
Maria Ilieva
Telerik team
Share this question
or