Click here to Skip to main content
13,042,789 members (75,689 online)
Rate this:
Please Sign up or sign in to vote.
Hi friends,
I am creating a web site which consist of games from different platforms and display information about it and registered users can comment on games.
So i need to create a page game.aspx?id='int value' and this page will contain picture of the game, title, description which is retrieved from sql server 2005.
Please help me I need to submit this project tomorrow.

In platforms page ill post games like in pc.aspx
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="pc.aspx.cs" Inherits="pc" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder_main" Runat="Server">
    <div class="block">
        <div class="block-bot">
          <div class="head">
            <div class="head-cnt">
              <h3>PC Games</h3>
              <div class="cl">&nbsp;</div>
          <div class="col-articles articles">
            <div class="cl">&nbsp;</div>
            <div class="article">
              <div class="image">
              <a href="game.aspx">
                <img src="App_Themes/Theme1/css/images/img4.jpg" alt="" />
              <h4><a href="#">F.E.A.R.2</a></h4>
            <div class="cl">&nbsp;</div>
<asp:Content ID="Content2" ContentPlaceHolderID="image_articles_games" Runat="Server">

for now i have loaded the pics from images folder in the server but I want to load images and other information from sql server 2005

and in game.aspx page i want to display the game pics, title, description, ratings, comments from database

Please help asap....
Posted 24-Aug-12 0:15am
gladiatron 24-Aug-12 6:41am
you really think getting a help on such short notice is possible in a non-real time platform like CP?? your best bet (only because of the time crunch) would be to get hold of a friend from your neighbourhood or class and work it out.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

on the flip side, this is one thing you can try. Store Image as bytes in the SQL server (think its blob type in SQL server 2005) and then create an HttpHandler to read the contents of that Image column and then do a Response.Write(<bytes>) from the handler to render the image on the page. The image tag's src would be the path of the handler file appended with a querystring say id=1, to fetch an image corresponding to a certain id.

See if this helps you.
rocksean30 24-Aug-12 7:00am
I know how to insert images in a grid view from database.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<head id="Head1" runat="server">
<title>Inserting images into databse and displaying images with gridview</title>
<style type="text/css">

<form id="form1" runat="server">
Image Name:
<asp:TextBox ID="txtImageName" runat="server">
Upload Image:
<asp:FileUpload ID="fileuploadImage" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click" />
<asp:GridView ID="gvImages" CssClass="Gridview" runat="server" AutoGenerateColumns="False"
HeaderStyle-BackColor="#7779AF" HeaderStyle-ForeColor="white"
BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
CellPadding="3" ForeColor="Black" GridLines="Vertical" Width="100%"
onrowdeleting="gvImages_RowDeleting" onrowediting="gvImages_RowEditing">
<asp:BoundField HeaderText = "Image Name" DataField="imagename"/>
<asp:TemplateField HeaderText="Image">
<asp:Image ID="Image1" runat="server" ImageUrl='<%# "ImageHandler.ashx?ImID="+ Eval("ImageID") %>' Height="300" Width="300" />

<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />

<FooterStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />

<HeaderStyle BackColor="Black" ForeColor="White" Font-Bold="True"></HeaderStyle>
<AlternatingRowStyle BackColor="#CCCCCC" />



<%@ WebHandler Language="C#" Class="ImageHandler" %>

using System;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public class ImageHandler : IHttpHandler {

string strcon = ConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString;

public void ProcessRequest(HttpContext context)
string imageid = context.Request.QueryString["ImID"];
SqlConnection connection = new SqlConnection(strcon);
SqlCommand command = new SqlCommand("select Image from mypics where ImageID=" + imageid, connection);
SqlDataReader dr = command.Execu
gladiatron 24-Aug-12 7:06am
You went over the limit for a comment because you decided to dump your code in the comment, which should have gone into where your question is. Now what is your question then?
rocksean30 24-Aug-12 7:04am
lol half of the comment is lost!!
I appreciate your fast reply @gladiatron
Please give me links which would help me in this project.
gladiatron 24-Aug-12 7:08am
I don't have any links specific to your problem, what i suggested is something what I would do. If you can show the images in the gridview surely u can extend that logic to showing images anywhere in the website.
rocksean30 24-Aug-12 7:10am
I want to load the images in separate div tags.
How can i do that ?
gladiatron 24-Aug-12 7:13am
i think if you use <asp:Panel> tag then you can use the same logic as your GridView to render images in there (using an <asp:Image> inside the panel), because the asp:Panel effectively gets renderd as a div on the browser.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web01 | 2.8.170713.1 | Last Updated 24 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100