Mokshasri

Mokshasri

  • NA
  • 31
  • 0

Urgent: Gridview image not displaying - asp.net 3.5 and oracle 9i

Dec 9 2009 4:31 PM
Hi Experts!
              Can anyone help me to solve this problem that I am facing with GridView in asp.net 3.5 ?

              Following is the code: .aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="displaytabledata.aspx.cs" Inherits="diplaydata.displaytabledata" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
        <asp:GridView ID="gv_displaydata" runat="server" BorderColor="#CC9966"
            BorderStyle="None" BorderWidth="1px"
               BackColor="White" CellPadding="4" Width="100%"
            AutoGenerateColumns="False" Height="129px"
            AllowPaging="true" onpageindexchanged="gv_displaydata_PageIndexChanged"
            onpageindexchanging="gv_displaydata_PageIndexChanging"
            onselectedindexchanged="gv_displaydata_SelectedIndexChanged" onselectedindexchanging="gv_displaydata_SelectedIndexChanging"
            >
            <Columns>
                <asp:BoundField FooterText="AUTHOR PHOT0" HeaderText="IMAGE">
                    <ControlStyle BackColor="#993300" BorderColor="#FFCC00" BorderStyle="Inset"
                        Font-Bold="True" Font-Size="Medium" Font-Underline="True" ForeColor="#FFFFCC" />
                    <FooterStyle BackColor="#FFFFCC" Font-Bold="True" ForeColor="#993300" />
                    <HeaderStyle BackColor="#993300" BorderColor="#FFCC00" BorderStyle="Inset"
                        Font-Bold="True" ForeColor="#FFFFCC" />
                </asp:BoundField>
                <asp:BoundField HeaderText="AUTHOR">
                <ControlStyle BackColor="#993300" BorderColor="#FFCC00" BorderStyle="Inset"
                        Font-Bold="True" Font-Size="Medium" Font-Underline="True" ForeColor="#FFFFCC" />
                    <FooterStyle BackColor="#FFFFCC" Font-Bold="True" ForeColor="#993300" />
                    <HeaderStyle BackColor="#993300" BorderColor="#FFCC00" BorderStyle="Inset"
                        Font-Bold="True" ForeColor="#FFFFCC" />
                </asp:BoundField>
                <asp:BoundField HeaderText="DESCRIPTION">
                <ControlStyle BackColor="#993300" BorderColor="#FFCC00" BorderStyle="Inset"
                        Font-Bold="True" Font-Size="Medium" Font-Underline="True" ForeColor="#FFFFCC" />
                    <FooterStyle BackColor="#FFFFCC" Font-Bold="True" ForeColor="#993300" />
                    <HeaderStyle BackColor="#993300" BorderColor="#FFCC00" BorderStyle="Inset"
                        Font-Bold="True" ForeColor="#FFFFCC" />
                </asp:BoundField>
            </Columns>
        </asp:GridView>
        <P>
            <asp:Label id="NotificationLabel" runat="server" Visible="False"></asp:Label>
            <asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
        </P>
    </div>
    </form>
</body>
</html>

and .aspx.cs code:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

// Application Import(s)
using images.Utilities;

namespace diplaydata
{

    public partial class displaytabledata : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bind();
            }
        }
        private DataTable getTable()
        {


            OracleDataAdapter adap = new OracleDataAdapter("select t.id, t.author, t.description from smstestblob t", "Data Source=ds1;User ID=test;Password=test;");

            DataTable dt = new DataTable();
            adap.Fill(dt);
            adap.Dispose();
            return dt;


        }


        protected void bind()
        {
            DataTable dr = getTable();
            gv_displaydata.DataSource = dr;
            gv_displaydata.DataBind();
        }

        protected void gv_displaydata_PageIndexChanged(object sender, EventArgs e)
        {
            gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
            bind();
        }


        protected void gv_displaydata_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
            bind();
        }

        protected void gv_displaydata_SelectedIndexChanged(object sender, EventArgs e)
        {
            gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
            bind();
        }
        protected void gv_displaydata_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gv_displaydata.PageIndex = gv_displaydata.PageIndex + 1;
            bind();
        }
}

}

No data is getting displayed in the GridView on both pages 1 and 2. And when I click on 2 page link, and then first page, 2nd  page link is no longer clickable.

I am using Oracle 9i. And following is the table creation script:

SQL> CREATE TABLE SMSTestBlob
  2  (
  3   id number,
  4   photo BLOB,
  5   author varchar2(100),
  6   description varchar2(500)
  7  );

Table created.

SQL> alter table SMSTESTBLOB
  2    add constraint PK_SMSTESTBLOB_ID primary key (ID);

Table altered.

SQL> create sequence smstestblobid_seq
  2  minvalue 1
  3  maxvalue 999999999999
  4  start with 1
  5  increment by 1
  6  cache 20
  7  cycle
  8  order;

Sequence created.

*************************************************
If anyone can help on this, please do so on an urgent basis.

Thanks,

Regards,
Moksha


Answers (6)