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

[Solved] Is GridImageColumn editable?

3 Answers 176 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jaimie
Top achievements
Rank 1
Jaimie asked on 30 Sep 2009, 06:05 AM
Hey.

I want to use GridImageColumn to display an image and edit the image (Replace the existing file, Upload new file if the name is different and save the new path to database). Instead of uploading the file into database, i only want to upload the actual file into a folder under the application server and save the path to the database

Is GridImageColumn okay for the display/edit purpose above? If not, how can i achieve the same function using Telerik control 2009 Q2?

jaimie

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 30 Sep 2009, 07:26 AM
Hi Jaimie,

One suggestion would be using GridTemplateColumn with image as ItemTemplate and RadUpload in EditItemTemplate of RadGrid. You can access the RadUpload control in UpdateCommand and update the database accordingly.

-Shinu.
0
Jaimie
Top achievements
Rank 1
answered on 01 Oct 2009, 03:13 AM
Hey.

Thanks for the reply.

I end up using something like this for the image column:

<telerik:GridTemplateColumn HeaderText="Image" DataField="Image" DataType="System.String" UniqueName="Image">
                    <ItemTemplate>
                        <asp:Image ID="WardenImage" Height="50px" Width="50px" runat="server" ImageUrl='<%#Bind("Image") %>' />
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox runat="server" ID="fileName" Columns="50" />            
                        <input type="button" onclick="OpenFileExplorerDialog('<%#Container.FindControl("fileName").ClientID %>'); return false;" value="Open ..." />  
                    </EditItemTemplate>
/telerik:GridTemplateColumn>


If i use EditForm in Grid and data bound the Grid to s SqlDataSource with Delete, Update, Insert command defined. When doing insert, update, how do i get the value from FileSelectorDiaglog Textbox then save it to database?
0
Mira
Telerik team
answered on 02 Oct 2009, 11:04 AM
Hi Jaimie,

To achieve the desired by you functionality, I recommend that you use the following code:
ASPX
                    <telerik:GridTemplateColumn HeaderText="Image" DataField="Image" DataType="System.String" 
                        UniqueName="Image"
                        <ItemTemplate> 
                            <asp:Image ID="WardenImage" Height="50px" Width="50px" runat="server" /> 
                        </ItemTemplate> 
                        <EditItemTemplate> 
                            <telerik:RadUpload runat="server" ID="RadUpload1" /> 
                        </EditItemTemplate> 
                    </telerik:GridTemplateColumn> 
and handle the ItemCommand event of the RadGrid:
C#
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
       if (e.CommandName == RadGrid.UpdateCommandName) 
        { 
            GridEditableItem editedItem = e.Item as GridEditableItem; 
            GridEditManager editMan = editedItem.EditManager; 
            IGridColumnEditor editor = editMan.GetColumnEditor("Image"); 
            string fileName = (editor.ContainerControl.FindControl("RadUpload1"as RadUpload)UploadedFiles[0].FileName; 
        } 
    } 

Find more information for RadUpload here.

I hope this will help you.

All the best,
Mira
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Jaimie
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jaimie
Top achievements
Rank 1
Mira
Telerik team
Share this question
or