Hi sowjanya,
I have created a sample which full fill your requirement
SQL
--===========SP==========--
CREATE PROCEDURE GetCustomers
AS
BEGIN
SELECT CustomerId
,Name
,Country
,dbo.FetchCustomerImage(CustomerId) AS CusImage
FROM Customers
END
----------------------------
--======FUNCTION=====---
CREATE FUNCTION FetchCustomerImage
(
@CustomerId INT
)
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @EmpImage NVARCHAR(MAX)
SELECT @EmpImage = FilePath + Name
FROM Files
WHERE Id = @CustomerId
RETURN (@EmpImage)
END
-----------------------------------------
HTML
<div>
<asp:GridView ID="gvCustomers" runat="server" AutoGenerateColumns="false">
<Columns>
</Columns>
</asp:GridView>
</div>
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BoundField customerId = new BoundField();
customerId.HeaderText = "CustomerId";
customerId.DataField = "CustomerId";
gvCustomers.Columns.Add(customerId);
BoundField name = new BoundField();
name.HeaderText = "Name";
name.DataField = "Name";
gvCustomers.Columns.Add(name);
BoundField country = new BoundField();
country.HeaderText = "Country";
country.DataField = "Country";
gvCustomers.Columns.Add(country);
ImageField img = new ImageField();
img.HeaderText = "Customers Image";
img.DataImageUrlField = "CusImage";//Your Column Name Representing the image.
gvCustomers.Columns.Add(img);
}
BindGrid();
}
private void BindGrid()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand cmd = new SqlCommand("GetCustomers", con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
sda.Fill(dt);
gvCustomers.DataSource = dt;
gvCustomers.DataBind();
}
Screenshot