2014年7月13日 星期日

[RESOLVED] How to show url of the image uploaded in database in gridview?


Hi,


Currently I have these setting showing on the page .



Name:


Address:


Image : Large image uploaded by user



I want it to be


Image: url of the image uploaded by user.



Can anyone help me out in this



This is code for showing up on the page I am using


employee page:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="employee.aspx.cs"
Inherits="Details_with_photo.employee" %>




Untitled Page






Details of Employee




Id : <%# Eval("id") %>


Name : <%# Eval("name")%>


Address : <%# Eval("address")%>


image








Employee code behind:


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 System.Data.SqlClient;
namespace Details_with_photo
{
public partial class employee : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["taConnectionString"].ConnectionString;
string str;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(strConnString);
con.Open();
str = "select id,name,address from employee";
com = new SqlCommand(str, con);
SqlDataReader reader;
reader = com.ExecuteReader();
repeater1.DataSource = reader;
repeater1.DataBind();
con.Close();
}
}
}

Kindly let me know thanks



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="employee.aspx.cs"
Inherits="Details_with_photo.employee" %>




Untitled Page






Details of Employee




Id : <%# Eval("id") %>


Name : <%# Eval("name")%>


Address : <%# Eval("address")%>


Image : image.aspx?id=<%# Eval("id")%>/>








is this what you mean?





Dr. Acula



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="employee.aspx.cs"
Inherits="Details_with_photo.employee" %>




Untitled Page






Details of Employee




Id : <%# Eval("id") %>


Name : <%# Eval("name")%>


Address : <%# Eval("address")%>


Image : image.aspx?id=<%# Eval("id")%>/>








is this what you mean?





It's showing like this now :



Id : 1

Name : ada

Address : dadsada

Image : image.aspx?id=1/>


Means no image.


I want it to be click able so that it can view.  Above has no clickable link.



ah ok, then you just use an a tag rather than an image tag


Image


image

Link


click me for image



Thank you. It works now.





Dr. Acula



ah ok, then you just use an a tag rather than an image tag
Image
image

Link


click me for image



I am also trying to show it in gridview but when I try to have image address which is in my database with the name photo it doesn't show up.


I only get id, address, name .



Here is the code ;



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="employee.aspx.cs"
Inherits="Details_with_photo.employee" %>




Untitled Page






Details of Employee




Id : <%# Eval("id") %>


Name : <%# Eval("name")%>


Address : <%# Eval("address")%>


click me for image





ConnectionString="<%$ ConnectionStrings:userConnectionString %>"
SelectCommand="SELECT * FROM [employee]">

AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">


ReadOnly="True" SortExpression="id" />

SortExpression="address" />





Can you please let me know how to have image url field as Click me for the image in gridview under photo table.


Thanks




Okay solved now Here is the final result :



<%@ Page Language="C#" AutoEventWireup="true" CodeFile="employee.aspx.cs"
Inherits="Details_with_photo.employee" %>




Untitled Page






Details of Employee




Id : <%# Eval("id") %>


Name : <%# Eval("name")%>


Address : <%# Eval("address")%>


click me for image





ConnectionString="<%$ ConnectionStrings:userConnectionString %>"
SelectCommand="SELECT * FROM [employee]">

AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">


ReadOnly="True" SortExpression="id" />

SortExpression="address" />

Image

click me for image








沒有留言:

張貼留言