I made an MVC project in Visual Studio 2015. The product file and the image file are closely related, from the product ID to the image product ID. Here, I can upload as many images as I want to a product, and I also delete the image I want. In the image file, the bigpath variable holds the path to the image. I also have an image folder. Physically, the images are kept here. The Büyükyol variable keeps the product images in the image table in the images folder. I can bring the images of the products very well, however, I could not build one of them in dataset1 for the Microsoft report. I put the two files in dataset1 and removed the dataadaptor part because I wanted to do this in the action, I did not want to use the dataadaptor in dataset1, but in the httppost section of my action section. The report is not being created, I am getting an error, it says the following, and I could not fill in the image properties contents in report1.rdlc.
I sent their picture to you, the code gives the following error in the action: "An error occurred during local report processing." In short, when I select the record from the product id, I want the pictures and records of the product id to be listed in the second table report1.rdlc.
I think the problem was in dataset1 and I couldn't solve the problem in designing the report. I couldn't edit the image element in report1.rdlc.
I want to use completely razor pages, not asp net pages. Best regards
part 1 view begining view
<td><a href="/urun/urunidrapor/@urunler.id" class="btn btn-danger">ID YE GORE RAPOR VE RESIMLER LİSTELE </a></td>
part2 chose id form
@using onibrticari.Models.ibrentity
@model urun
@{
ViewBag.Title = "RAPOR";
Layout = "~/Views/Shared/Anamasterform.cshtml";
}
<div class="row">
<div class="col-md-offset-12">
<div class="panel-primary">
<form action="/urun/urunidRaporPost" method="post">
@*asagıdakı ıd urun kutugundekı ıd dır*@
@*BURDA FORMU POST EDERKEN ASAGIDAKI INPUTTAKI ID YI DE PARAMETRE OLARAK GONDERIR*@
<input type="hidden" name="urunId" value="@Model.id" />
<label>@Model.adi ===> ADLI URUN RAPORLANSINMI </label>
<input type="submit" value="EVET" />
</form>
</div>
</div>
</div>
part 3 actions part
public ActionResult UrunIdRapor(int urunId) // part 2 view action be careful
{
// Veritabanından belirli bir ürünü al
urun ut1 = db.urun.FirstOrDefault(x => x.id == urunId);
if (ut1 != null)
{
return View(ut1);
}
else
{
// Eğer belirli bir ürün bulunamazsa, başka bir işlem yapabilirsiniz
return RedirectToAction("Index");
}
}
[HttpPost]
public ActionResult urunidRaporPost(int urunId)
{
// Veritabanından belirli bir ürünü al
urun ut1 = db.urun.FirstOrDefault(x => x.id == urunId);
// Veritabanından ürüne ait resim verilerini al
List<resim> resimler = db.resim.Where(r => r.urunid == urunId).ToList();
if (ut1 != null && resimler.Any())
{
string path = Path.Combine(Server.MapPath("~/rapor"), "Report1.rdlc");
if (System.IO.File.Exists(path))
{
LocalReport lr = new LocalReport();
lr.ReportPath = path;
// Rapor veri kaynaklarını oluşturun
ReportDataSource rd = new ReportDataSource("dataset1", new List<urun> { ut1 });
ReportDataSource rd2 = new ReportDataSource("dataset2", resimler);
// Rapor veri kaynaklarını rapora ekleyin
lr.DataSources.Add(rd);
lr.DataSources.Add(rd2);
// Rapor oluşturma işlemleri devam eder...
byte[] bytes = lr.Render("PDF");
// PDF dosyasını kullanıcıya indirme olarak sun
return File(bytes, "application/pdf", "rapor.pdf");
// Raporu kullanıcıya göstermek için uygun bir yöntem kullanın
}
else
{
return RedirectToAction("Index");
}
}
return RedirectToAction("Index");
}
part 4 urun class with ado entity
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace onibrticari.Models.ibrentity
{
using System;
using System.Collections.Generic;
public partial class urun
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public urun()
{
this.marka = new HashSet<marka>();
this.resim = new HashSet<resim>();
this.satisdetay = new HashSet<satisdetay>();
}
public int id { get; set; }
public string adi { get; set; }
public string aciklama { get; set; }
public Nullable<decimal> alisfiyat { get; set; }
public Nullable<decimal> satisfiyat { get; set; }
public Nullable<System.DateTime> eklenmetarihi { get; set; }
public Nullable<System.DateTime> sonkullanmatarihi { get; set; }
public Nullable<int> kategoriid { get; set; }
public Nullable<int> tedarikid { get; set; }
public Nullable<int> markaid { get; set; }
public Nullable<int> stok { get; set; }
public Nullable<decimal> fiyat { get; set; }
public string resimyolu { get; set; }
public Nullable<int> resimid { get; set; }
public Nullable<bool> sonlandi { get; set; }
public virtual kategori kategori { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<marka> marka { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<resim> resim { get; set; }
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
public virtual ICollection<satisdetay> satisdetay { get; set; }
public virtual tedarik tedarik { get; set; }
}
}
part 4 resım class with ado entity
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace onibrticari.Models.ibrentity
{
using System;
using System.Collections.Generic;
public partial class resim
{
public int id { get; set; }
public string buyukyol { get; set; }
public string ortayol { get; set; }
public string kucukyol { get; set; }
public Nullable<bool> varsayilan { get; set; }
public Nullable<int> urunid { get; set; }
public Nullable<int> markaid { get; set; }
public virtual marka marka { get; set; }
public virtual urun urun { get; set; }
}
}
report1.rdlc dosyası
report data
images
data source
datasets
dataset1 urun table designer table
id id head adi head
adi id adi
aciklama
alisfiyat
satisfiyat
eklenme tarihi
sonkullanmatarihi
kategoriid
tedarikid
markaid
stok
fiyat
resimyolu
resimid
sonlandi
resim table designer table
dataset2 id head buyukyol head image
id id buyukyol image element
buyukyol
ortayol
kucukyol
varsayilan
urunid
markaid
note : image tagının içine yol veremedim sen ver imagenin ppropertiesini düzenleyemedim
dataset1 dosyası
urun table resim table
id id
adi buyukyol
aciklama ortayol
alisfiyat kucukyol
satisfiyat varsayilan
eklenmetarihi urunid
sonkullanmatarihi markaid kategoriid
tedarikid
markaid
stok
fiyat
resimyolu
resimid
sonlandi
The id line in the product table is closely related to 1 to the product id variable in the image table. Remember, there is a line here.