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

GridBinaryImageColumn Question

5 Answers 149 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 12 May 2010, 07:06 PM
I've got a GridBinaryImageColumn  in my radgrid. I've got ajax enabled. I've got the javascript to do the disabling for image uploads (args.set_enableAjax(false);). I'm getting the database populated. I'm actually getting data back (binary) when the grid is displayed. HOWEVER, it's never displaying an image. I get a broken image tag because there is no src attribute ever added.

Can someone give me a place to troubleshoot, because I've been through about all I know. Looked into the db, used sql profiler to see what's coming in/out.... just no good. Am I missing something obvious?

My column:
<telerik:GridBinaryImageColumn DataField="Photo" HeaderText="Image" UniqueName="Upload" ImageAlign="NotSet"
                        ImageHeight="80px" ImageWidth="80px" ResizeMode="Fit" DataAlternateTextField="Description"
                        DataAlternateTextFormatString="Image of {0}">
                        <HeaderStyle Width="10%" />

Insert (this is working, data goes to db)
protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
        {

            RadUpload uplPhoto = (RadUpload)e.Item.FindControl("uplPhoto");

            foreach (UploadedFile file in uplPhoto.UploadedFiles)
            {
                byte[] bytes = new byte[file.InputStream.Length];
                file.InputStream.Read(bytes, 0, (int)file.InputStream.Length);

                SPPDataContext data = new SPPDataContext();
                Gallery gal = new Gallery();
                gal.Photographer = (Guid)Membership.GetUser().ProviderUserKey;
                gal.Name = ((RadTextBox)e.Item.FindControl("txtPhotoName")).Text;
                gal.Description = ((RadTextBox)e.Item.FindControl("txtPhotoName")).Text;
                gal.Photo = bytes;

                data.Galleries.InsertOnSubmit(gal);

                data.SubmitChanges();
            }
        }

Pulling data by linqdatasource:

<asp:LinqDataSource ID="ldsPortfolioGrid" runat="server"
                ContextTypeName="SPP.Web.Data.SPPDataContext" OrderBy="Name"
                TableName="Galleries" Where="Photographer == @Photographer"
                onselecting="ldsPortfolioGrid_Selecting" EnableDelete="True"
                EnableInsert="True" EnableUpdate="True" oninserted="ldsPortfolioGrid_Inserted"
                oninserting="ldsPortfolioGrid_Inserting">
                <WhereParameters>
                    <asp:Parameter DbType="Guid" Name="Photographer" />
                </WhereParameters>
            </asp:LinqDataSource>

Selecting is doing nothing exciting either:
protected void ldsPortfolioGrid_Selecting(object sender, LinqDataSourceSelectEventArgs e)
        {
            e.WhereParameters["Photographer"] = Membership.GetUser().ProviderUserKey;
        }







Thanks in advance guys!


5 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 13 May 2010, 01:40 PM
Hi Michael,

Can you please verify that you have registered the RadBinaryImage handler in the webconfig? Should should have similar to the following entries:

Classic mode:
<httpHandlers>
      ...
      <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
</httpHandlers>

Integrated mode:
<system.webServer>
    ...
    <handlers>
        <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
    </handlers>
</system.webServer>

Kind regards,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Michael
Top achievements
Rank 1
answered on 13 May 2010, 02:00 PM
Indeed:

<system.webServer> 
        <validation validateIntegratedModeConfiguration="false"/> 
        <modules> 
            <add name="RadUploadModule" preCondition="integratedMode" type="Telerik.Web.UI.RadUploadHttpModule"/> 
        </modules> 
        <handlers> 
            <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource"/> 
            <add name="Telerik_RadUploadProgressHandler_ashx" verb="*" preCondition="integratedMode" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler"/> 
            <add name="Telerik_Web_UI_DialogHandler_aspx" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler"/> 
        </handlers> 
    </system.webServer> 
 
 
 
<pages theme="Default" controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"
        </pages> 
        <httpHandlers> 
            <add verb="*" path="/articles/*.aspx" type="SPP.Web.HttpHandlers.ArticleHandler, SPP.Web"/> 
            <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false"/> 
            <add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false"/> 
            <add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false"/> 
        </httpHandlers> 
        <httpModules> 
            <add name="PhotogListings" type="SPP.Web.Modules.PhotogListings"/> 
            <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule"/> 
        </httpModules> 
    </system.web> 
0
Rosen
Telerik team
answered on 14 May 2010, 03:38 PM
Hello Michael,

Can you please provide more details about the implementation? Maybe you can paste (using format code block) the page's code here?

Kind regards,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Michael
Top achievements
Rank 1
answered on 18 May 2010, 03:23 PM
I got this lined out. It has to do with the Linq Data Source. I'd created my dbml file via drag and drop in my studio IDE from the server explorer, by dragging the database tables over. It marked my image column as a System.Data.Linq.Binary. By simply changing it to a Byte[] it started showing images again.
0
Larry
Top achievements
Rank 1
answered on 01 Aug 2010, 07:25 PM
Hey Michael,

Thank you very much for sharing your code!  I was just poking around to try and get my image upload working and your example code fit the bill very nicely!  I understand that wasn't fully the intent, but I felt obliged to let you know that even questions can sometimes be answers.

Larry
Tags
Grid
Asked by
Michael
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Michael
Top achievements
Rank 1
Larry
Top achievements
Rank 1
Share this question
or