Well, im a beginner and im having some problems with the code. On the display it shows System.Data.Objects.ObjectQuery 1[System.String]. Im stuck. I will be grateful for your help.

 private void grdProdukti_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {
                int PID = int.Parse( e.FormattedValue.ToString()) ;


                grdProdukti.CurrentRow.Cells["Produkt"].Value =
                from tretmanProdukt in tretmanProdukti.Produkti
                where tretmanProdukt.ProduktID == PID
                select tretmanProdukt.Naziv;


            }

anybody with an idea? do you need more information? i sure this part of the code is where the problem is.

This code probably is where the problem is. However without the code showing the class(es) represented in your code, it's pretty hard to decipher what exactly your code is doing.

e4aae72acb69a311a8214c4e87fc00a8 Im trying to merge two diferent tabels by taking Naziv from a different table and adding it to the grid.Another table for the combo(three tables) And here is the complete code from the class:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AppKozmetika
{
    public partial class frmTretmaniProdukti : Form
    {
        KozmetikaEntitiess tretmanProdukti = new KozmetikaEntitiess();

        public frmTretmaniProdukti()
        {
            InitializeComponent();
        }

        public frmTretmaniProdukti(frmMain parent)
        {
            InitializeComponent();
            MdiParent = parent;
        }

        private void frmTretmaniProdukti_Load(object sender, EventArgs e)
        {
            cmbTretman.DisplayMember = "Naziv";
            cmbTretman.ValueMember = "TretmanID";
            cmbTretman.DataSource =
                from tretman in tretmanProdukti.Tretmani 
                orderby tretman.TretmanID 
                select tretman ;
        }

        private void cmbTretman_SelectedIndexChanged(object sender, EventArgs e)
        {
            int TID = int.Parse(cmbTretman.SelectedValue.ToString() );

            tretman_ProduktiBindingSource.DataSource =
                from tretmanProdukt in tretmanProdukti.Tretman_Produkti
                where tretmanProdukt.TretmanID == TID
                orderby tretmanProdukt.ProduktID
                select tretmanProdukt;

            grdProdukti.DataSource = tretman_ProduktiBindingSource;


        }

        private void tretman_ProduktiBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            Validate();
            tretman_ProduktiBindingSource.EndEdit();
            tretmanProdukti.SaveChanges();
            MessageBox.Show("Снимено", "", MessageBoxButtons.OK);
        }

        private void NapolniCombo()
        {
            DataGridViewComboBoxColumn colProduktID = new DataGridViewComboBoxColumn();
            colProduktID = grdProdukti.Columns["ProduktID"] as DataGridViewComboBoxColumn;

            colProduktID.ValueMember = "ProduktID";
            colProduktID.DisplayMember = "Naziv";
            colProduktID.DataSource =
                from produkt in tretmanProdukti.Produkti
                orderby produkt.Naziv
                select produkt;
        }


        private void grdProdukti_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
        {
            grdProdukti.CurrentRow.Cells["TretmanID"].Value =  int.Parse(cmbTretman.SelectedValue.ToString());
        }

        private void grdProdukti_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (e.ColumnIndex == 1)
            {
                int PID = int.Parse( e.FormattedValue.ToString()) ;


                grdProdukti.CurrentRow.Cells["Produkt"].Value =
                from tretmanProdukt in tretmanProdukti.Produkti
                where tretmanProdukt.ProduktID == PID
                select tretmanProdukt.Naziv;


            }
        }
This article has been dead for over six months. Start a new discussion instead.