Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to Display Images in a Grid in a ModuleHow to Display Images in a Grid in a Module
Previous
 
Next
New Post
3/9/2008 6:20 PM
 

Hello,

I am new to DNN and would like to create a C# module that shows some pictures in a grid. I was able to create one using the template from the Starter Kit /Version 4.8.0/ and connect it to the MS SQL database so that it displays some text info. I am not sure what is the best way to display the images.

This thread has an example of how to accomplish this task, but it connects directly to the database and I would like to use the DNN DAL instead.

Any help is appreciated!

Eis Karlsson

 
New Post
3/11/2008 9:15 AM
 

Where are the images?

I did something similar a few years back.i stored the image path in the database, and used a datarepeater to list the images. For help with hooking up the data, see michael washington's tutorials.

< asp:image ImageUrl='<%# Eval("ImagePath") %>'

OR

< asp:image ImageUrl='<%# "~/DesktopModules/ImageViewer/Images/" + Eval("ImageName") %>'

 
New Post
3/11/2008 8:36 PM
 

Thanks for answering.

The images are stored as byte arrays in the database. Some examples show that I need additional information like the type of image and the size of the array. I would like to use just one column in the data table. Is that possible?

Anyway did you see this link in my post above. It seems like that is one way to pull the images from the database. It looks like to me though that a direct connection to the database is used, instead of the DNN Data Access Layer. I wonder if this layer can be used. I will take a look at Michael Washington's tutorials, but I used a book to connect the database to the module and the grid. The code is something like:

 MyCompanyController objMyComps = new MyCompanyController();

List<MyCompanyInfo> colMyCompanys;

colMyCompanys = objMyCompanys.GetMyCompanys(ModuleId);

Grid1.DataSource = colMyCompanys;

Grid1.DataBind();

 

It works fine for text data, but I am not sure where to place the code for retrieving the images. Should I add a http handler, aspx page or just use the module control? 

 

 
New Post
3/12/2008 9:46 AM
 

Sorry I don't have experience with storing images in the database and I'm not sure how you would store all that info in one column. Perhaps someone else can help out.  You also don't have to use the DAL in your module, it's optional.

 
New Post
3/17/2008 8:49 PM
 

I think I figured it out:

I placed the code in an aspx page in the module folder and removed the <form> tags from it. The codebehind is shown here:

ViewImage.aspx.cs

{insert the necessary using statements here}

 

namespace MyCompany.Modules.MyModule

{

 

    public partial class ViewImage : System.Web.UI.Page

 

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            int imageId;

            int moduleId;

            if ((Request.QueryString["imageId"] == null) || (Request.QueryString["moduleId"] == null))

                return;

            if (!(int.TryParse(Request.QueryString["imageId"].ToString(), out imageId)))

                return;

            if (!(int.TryParse(Request.QueryString["moduleId"].ToString(), out moduleId)))

                return;

            writeImage(moduleId, imageId);

 

        }

        protected void writeImage(int _ModuleID, int _ItemID)

        {

            MyModuleController objMyModulePerson = new MyModuleController();

            MyModuleInfo MyModulePerson = new MyModuleInfo();

            MyModulePerson = objMyModulePerson.GetMyModule(_ModuleID, _ItemID);

 

          

            if (MyModulePerson.CreatedByUser > 0)

            {

                if (MyModulePerson.Picture.Length != 0)

                    Response.BinaryWrite(MyModulePerson.Picture);

            }

 

 

        }

    }

}

The code for the grid, which is pretty simple is in the module ascx file. I am not going to post it, because I used a third-party component, but if you are interested you can follow this link.

Hope this helps somebody.

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0How to Display Images in a Grid in a ModuleHow to Display Images in a Grid in a Module


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out