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



in database table is thier . in that table fields are photoid , photoname,photo... i want display ..

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

in database table is thier . in that table fields are photoid , photoname,photo... i want display ..

Answer / nagaraj

pls post a mail to below mail id answer if any knows

Is This Answer Correct ?    2 Yes 0 No

in database table is thier . in that table fields are photoid , photoname,photo... i want display ..

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

in database table is thier . in that table fields are photoid , photoname,photo... i want display ..

Answer / deepika

Use template column and put image as control in the
itemTemplate

Is This Answer Correct ?    2 Yes 1 No

in database table is thier . in that table fields are photoid , photoname,photo... i want display ..

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

Post New Answer

More ASP.NET Interview Questions

Explain about Multi-Language integration?

0 Answers  


What is strong-typing versus weak-typing?

0 Answers  


Where can i get Latest Microsoft .Net Certification Dumps & what Types of .Net Certifications are there?

2 Answers   Protech,


is it possible to use web site without web server from remote place?

1 Answers   ABC, Mannar Company, Quadrant,


what is diffrent between asp & asp.net

2 Answers  






Can you store dataset in viewstate?

7 Answers   Microsoft,


How you can add an event handler?

0 Answers  


when i want to use asp.net configuration for creat users and roles i recived this message: There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store. The following message may help in diagnosing the problem: Unable to connect to SQL Server database. when i clicked the choose data source button that give me another message that is this: Use this page to configure how Web site management data such as membership is stored. You can use a single provider for all the management data for your site or you can specify a different provider for each feature. Your application is currently configured to use the provider: AspNetSqlProvider Select a single provider for all site management data Select a different provider for each feature (advanced) ------------------------- and this message was reapeted in other choose again. please help me if u know why i gave that message so i wont can creat my users and roles

0 Answers  


Explain how does asp page work?

0 Answers  


How will you do Redo and Undo in a TextControl?

0 Answers  


Is LINQ performance wise better or using sqlcommand?

1 Answers  


Define xmlvalidatingreader class.

0 Answers  


Categories