locked
how to bind in one grid with different grids? RRS feed

  • Question

  • User932259438 posted

    hello,

    I want to use Union for retrieve different data with the same columns names but I can't do this.

    My code:

    var skupaj = (from p in db.tbl_PotniNalogis
    join t in db.tbl_relacijes
    on p.ID equals t.IDRelacija
    where p.DatumIzdaje >= new DateTime(yearod, monthod, dayod) && p.DatumIzdaje <= new DateTime(yeardo, monthdo, daydo) && p.Idkreiranopodjetje == Convert.ToInt32(Session["ID"])
    orderby p.Leto, p.Stevilka
    group t by new { p.Stevilka, p.Leto, p.Voznik, p.Vozilo, t.Relacija, t.OpisNamena, p.ZacetnoStanje, p.KoncnoStanje, t.DatumRelacije } into g
    select new { OpisKnjizbe = "km domaca", Konto = 41410, STM = "sm", MES_OBDOB = g.Key.DatumRelacije.Value.Month, LETO_OBDOB = g.Key.Leto, DEBET = "", DEBET_VAL = "", KREDIT_VAL = "", POTNIK = g.Key.Voznik, SIF_VAL = "EUR", PROKO = "", POSEL = "pn", VP = "", SIF_PP = "", RACUN = g.Key.Stevilka + "/" + g.Key.Leto, DAT_DOK = "", DAT_DUR = "" }).Union
    (from p in db.tbl_PotniNalogis
    join t in db.tbl_dnevnice_obracuns
    on p.ID equals t.IDDnevnica
    where p.DatumIzdaje >= new DateTime(yearod, monthod, dayod) && p.DatumIzdaje <= new DateTime(yeardo, monthdo, daydo) && t.Valuta == "EUR" && p.Idkreiranopodjetje == Convert.ToInt32(Session["ID"]) //t.IDDnevnica == Convert.ToInt32(Session["ID"])
    orderby p.Leto, p.Stevilka
    group t by new { p.Stevilka, p.Leto, p.Voznik, t.DnevnicaZa, t.DnevnicaOdCas, t.DnevnicaDoCas } into g
    select new { OpisKnjizbe = "dnevnice domace", Konto = 41400, STM = "sm", MES_OBDOB = g.Key.DnevnicaDoCas.Value.Month, LETO_OBDOB = g.Key.DnevnicaDoCas.Value.Year, DEBET = "", DEBET_VAL = "", KREDIT_VAL = "", POTNIK = g.Key.Voznik, SIF_VAL = "EUR", PROKO = "", POSEL = "pn", VP = "", SIF_PP = "", RACUN = g.Key.Stevilka + "/" + g.Key.Leto, DAT_DOK = "", DAT_DUR = "" });

    What is best way for that?

    Regards

    Wednesday, December 18, 2019 12:45 PM

All replies

  • User1535942433 posted

    Hi progy85,

    As far as I know. if you want to use union to combine two table, you should also make sure the column type is the same.

    Besides, you say you faced the error. Please post the details error message and table schema for us to reproduce the issue.

    Best regards,

    Yijing Sun

    Thursday, December 19, 2019 9:14 AM