in database table is thier . in that table fields are
photoid , photoname,photo... i want display image in the
gridview
Answers were Sorted based on User's Feedback
Answer / .....
initially while inserting image into database take the
database field in oracle as BLOB in sql as image
during insertion convert the image file into bytes and
insert it into the database
during the display of image in datagrid take a image
template and display the converted values
sample code to get the image:
public byte[] spic(string cm,int id)
{
con = new OracleConnection(cm);
OracleCommand cmd = new OracleCommand("select
photo from kir_image where eid= "+id +" ", con);
con.Open();
byte[] img = (byte[])cmd.ExecuteScalar();
con.Close();
return img;
}
use Response.BinaryWrite to display the image
Is This Answer Correct ? | 3 Yes | 0 No |
Answer / nagaraj
pls post a mail to below mail id answer if any knows
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / krishnasamy2008
Using C#(Asp.net)
-------------
<asp:TemplateColumn HeaderText ="Photo" >
<ItemTemplate>
<asp:image
</ItemTemplate>
<asp:Image ID="udphoto" ImageUrl='<%#Eval("Photo")%>'
runat="server" />
<HeaderStyle ForeColor ="blue" />
</asp:TemplateColumn>
Using Vb.Net(Asp.net)
-------------
<asp:TemplateColumn HeaderText ="Photo" >
<ItemTemplate>
<asp:image
</ItemTemplate>
<asp:Image ID="udphoto"
ImageUrl='<%#DataBinder.Eval(Container.DataItem,"Photo")%>'
runat="server" />
<HeaderStyle ForeColor ="blue" />
</asp:TemplateColumn>
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / deepika
Use template column and put image as control in the
itemTemplate
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / appu
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataKeyNames="ID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID"
InsertVisible="False" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField="ImageName" HeaderText="ImageName"
SortExpression="ImageName" />
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# "Handler.ashx?ID=" + Eval("ID")%>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ID], [ImageName], [Image]
FROM [Images]"></asp:SqlDataSource>
Handler.ashx
<%@ WebHandler Language="C#" Class="Handler" %>
using System;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context)
{
SqlConnection con = new SqlConnection();
con.ConnectionString = ConfigurationManager.ConnectionStrings
["ConnectionString"].ConnectionString;
// Create SQL Command
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "Select ImageName,Image from Images" +
" where ID =@ID";
cmd.CommandType = System.Data.CommandType.Text;
cmd.Connection = con;
SqlParameter ImageID = new SqlParameter
("@ID", System.Data.SqlDbType.Int);
ImageID.Value = context.Request.QueryString["ID"];
cmd.Parameters.Add(ImageID);
con.Open();
SqlDataReader dReader = cmd.ExecuteReader();
dReader.Read();
context.Response.BinaryWrite((byte[])dReader["Image"]);
dReader.Close();
con.Close();
}
Is This Answer Correct ? | 1 Yes | 0 No |
From the given paragraph of text, write a program to match the strings of format “Any number of numerals followed by an underscore followed by any number of alphabets" ex:123_abc (Note:using regular expressions)
What are the differences between Trace and Debug?
What is the latest version of asp.net?
What is the Web.config file used for? a) To store the global information and variable definition for the application. b) Configures the time that the server-side codebehind module is called c) To Configure the Web Server. d) To Configure the Web browser.
8 Answers HCL, IBM, Syntax Softtech, Vypin, WideVision Technologies,
Explain the server control events of asp.net ?
Where can i get Latest Microsoft .Net Certification Dumps & what Types of .Net Certifications are there?
Explain Factory pattern?
Describe the differences between the lifecycles of Windows services and Standard EXE?
and can u telme how to explain about our job profile if i have 3years of it experiance in dotnet domain and where to start and where to end , and what shoul i tel and what not(can i mention my education ,and family details,......)i am confusiong a lot. can i ask one with your permision, if u have question that u u went tcs interview as 3+years exp so he/she asked tel me about your profile how can u tel and where to stop. please help me as simple as possible i am facing lot in this..............plese can anyone help me i am awaiting for your reply.
How do you create a permanent cookie?
How do you handle unhandled exceptions in ASP.NET?.
what is the difference between primary key and foreign key?