ASP.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a ASP.NET Expert!

Join 307,220 ASP.NET Programmers for FREE! Get instant access to thousands of ASP.NET experts, tutorials, code snippets, and more! There are 1,691 people online right now. Registration is fast and FREE... Join Now!




Regarding showing image

 

Regarding showing image, using C# technology

er.omprakash

27 Jul, 2009 - 02:48 AM
Post #1

New D.I.C Head
*

Joined: 2 Sep, 2008
Posts: 4

i have a gridview there are three field like,ID,image,Name and also a link print in gridview . retrieve all record from database showing in Gridview i have done it.but when i click link buttion in gridview then show all record

html
<tr bgcolor="#f2f2f2" class="black"> 
<td height="25" style="width: 15px"> </td>
<td ><div align="left">ID*:  </div></td>
<td style="text-align: left" id="ct" runat="server" ></td>
<td> </td>
</tr>

<tr bgcolor="#f2f2f2" class="black">
<td height="25" style="width: 15px"> </td>
<td ><div align="left">name :  </div></td>
<td style="text-align: left" id="fname" runat="server" ></td>
<td> </td>
</tr>
<asp:Image ID="Image1" Width="120" Height="120" runat="server" ImageAlign ="Middle" ImageUrl='<%#"pagename.aspx?id=" + Eval("ID")%>' />

and ASPX page Code i have do

csharp

protected void Page_Load(object sender, EventArgs e)
{
conn = new SqlConnection("data source=(local);uid=sa;pwd=sa;initial catalog=databasename");


cmd = new SqlCommand("select name,ID,impimg from tablename where ID='" + Request.QueryString.Get("id") + "'");

cmd.Connection = conn;
conn.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
fname.InnerHtml = dr["name"].ToString();

ct.InnerHtml = dr["ID"].ToString();

}


}


.
two record dislaying but Image not display .
i want show one by one record when click print buttion please help me.

*** MOD EDIT: Added code tags. Please code.gif ***

This post has been edited by JackOfAllTrades: 27 Jul, 2009 - 08:37 AM

User is offlineProfile CardPM
+Quote Post


JackOfAllTrades

RE: Regarding Showing Image

27 Jul, 2009 - 08:38 AM
Post #2

I exist to Google your problems.
Group Icon

Joined: 23 Aug, 2008
Posts: 5,324



Thanked: 454 times
Dream Kudos: 50
Expert In: Being annoyed with lazy people.

My Contributions
Moving to ASP.NET.
User is offlineProfile CardPM
+Quote Post

Jayman

RE: Regarding Showing Image

27 Jul, 2009 - 04:01 PM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 8,570



Thanked: 237 times
Dream Kudos: 500
Expert In: Everything

My Contributions
You need to set the ImageUrl property of the Image tag to the URL where the actual image is located.

I am assuming that impimg returns a valid URL to the image. If not, then you will need to modify it to make it one.
CODE

            while (dr.Read())
            {
                fname.InnerHtml = dr["name"].ToString();          
                ct.InnerHtml = dr["ID"].ToString();
                Image1.ImageUrl = dr["impimg"].ToString();
            }


Remove the binding.
CODE

<asp:Image ID="Image1"  Width="120" Height="120"  runat="server" ImageAlign ="Middle"  />

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 10:33PM

Live ASP.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

ASP.NET Tutorials

Reference Sheets

ASP.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month