0
Hi guys i have proplem
I have 100 employee showing in datagridview and i have path that have these pictures to all employee found in
this path
\\\\192.168.1.10\\24.10.11
what i need is to show every employee have picture in this path in datagridview as following
datagridview1
employeeNo EmployeeName image
555 adil picture path from \\\\192.168.1.10\\24.10.11 related to this employee
556 wadel picture path from \\\\192.168.1.10\\24.10.11 related to this employee
How to get image from specified path according to EmployeeID BY C# CODE
Dipankar BiswasPosted Aug 31, 2014, 4:51 AM
ahmed saPosted Aug 30, 2014, 1:37 AM
Thank you for reply
but i work in windows application c# not web application
and i need to show the image from path in server not from database
Dipankar BiswasPosted Aug 29, 2014, 1:48 PM
Aspx...............
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DisplayImages.aspx.cs" Inherits="UpLoadimages.DisplayImages" %>
aspx.cs...............
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.IO;
namespace UpLoadimages
{
public partial class DisplayImages : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=192.168.4.85;Database=Chinnu;User Id=sa;Password=Admin1234;");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGridData();
}
}
private void BindGridData()
{
try
{
SqlCommand command = new SqlCommand("SELECT * from Display_Images", con);
SqlDataAdapter da = new SqlDataAdapter(command);
DataTable dt = new DataTable();
da.Fill(dt);
gridview.DataSource = dt;
gridview.DataBind();
}
catch (Exception ex)
{
}
}
protected void BtnUploadImages_Click(object sender, EventArgs e)
{
if (FileUpload1.PostedFile != null)
{
string ImageName = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.SaveAs(Server.MapPath("DisplayImages/" + ImageName));
string Query = "Insert into Display_Images(ImageName,ImagePath)" + "values(@ImageName,@ImagePath)";
SqlCommand cmd = new SqlCommand(Query);
cmd.Connection = con;
cmd.Parameters.AddWithValue("@ImageName", ImageName);
cmd.Parameters.AddWithValue("@ImagePath", "DisplayImages/" + ImageName);
cmd.CommandType = CommandType.Text;
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
}
}
}