I have a code like this. This code works fine in Reportviever, but the images do not appear. There are two list elements, report1.rdlc. Among them, there are elements of the product dataset coming from mydataset.
In this, product dataset id and name image dataset id, product id and buyukyol buyukyol also takes the path of the image files in the pictures folder like / pictures / 1.jpg / pictures / 2.jpg. I said image in the 2nd list element. ise = Fields!buyukyol.Value I said this, the images do not appear, but if I say like this
I said = external. If I say "file://"+Fields!buyukyol.value to the value, it puts the same image in all the images that the product id is related to. In short, = Fields!buyukyol.Value. This does not work. For some reason, I added this in the field (image) main title in fx.
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string deger = Request.QueryString["bulid"];
mydataset dataSet = new mydataset();
// Veritabanı bağlantısı ve sorgu oluşturma
string connectionString = @"Data Source=DESKTOP-1B3OQRL;Initial Catalog=ibroz;Integrated Security=True";
// SqlConnection, SqlDataAdapter ve DataTable kullanarak veritabanından veri alabilirsiniz
using (SqlConnection connection = new SqlConnection(connectionString))
{
// Veritabanından veri çekme
SqlDataAdapter da = new SqlDataAdapter("SELECT urun.*, resim.* FROM urun INNER JOIN resim ON urun.id = resim.urunid WHERE urun.id = @id", connection);
da.SelectCommand.Parameters.AddWithValue("@id", deger);
// "urun" ve "resim" tablolarını ayrı ayrı doldurma
DataTable urunTable = new DataTable("urun");
DataTable resimTable = new DataTable("resim");
da.Fill(urunTable);
da.Fill(resimTable);
// DataSet'e tabloları ekleme
dataSet.Tables.Add(urunTable);
dataSet.Tables.Add(resimTable);
// Toplam uygun kayıt sayısını başlatma
int uygunKayitSayisi = 0;
// Her bir resim için işlem yapma
foreach (DataRow row in dataSet.Tables["resim"].Rows)
{
// Resim bilgilerini al
string urunid = row["urunid"].ToString();
string resimYolu = "resimler/" + row["buyukyol"].ToString(); // Resimler klasörünü düzeltme
// Eğer resmin urunid'si belirtilen değere eşitse işlem yap
if (urunid == deger)
{
// Her bir uygun kayıt için pop-up mesajını göster
string script = "alert('ID: " + row["id"] + ", UrunID: " + urunid + ", BuyukYol: " + resimYolu + "');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "popup" + urunid + Guid.NewGuid().ToString(), script, true);
// Resmi ekrana göster
string resimScript = "<script>var resim = new Image(); resim.src = '" + resimYolu + "'; document.body.appendChild(resim);</script>";
ScriptManager.RegisterStartupScript(this, this.GetType(), "resim" + urunid + Guid.NewGuid().ToString(), resimScript, false);
// Her bir uygun kayıt için uygun kayıt sayısını arttır
uygunKayitSayisi++;
}
}
// Veri kaynaklarını rapora ekleme (sadece resim tablosunu kullanıyoruz)
ReportViewer1.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
ReportViewer1.LocalReport.ReportPath = Server.MapPath("report1.rdlc");
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("urun", dataSet.Tables["urun"]));
ReportViewer1.LocalReport.DataSources.Add(new ReportDataSource("resim", dataSet.Tables["resim"]));
ReportViewer1.LocalReport.EnableExternalImages = true;
ReportViewer1.LocalReport.Refresh();
// Toplam uygun kayıt sayısını bildiren mesajı göster
string mesaj = "alert('Toplam " + uygunKayitSayisi + " kayıt bulundu.');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "kayitBilgilendirme" + Guid.NewGuid().ToString(), mesaj, true); bir
}
}
}