Display Value - inner join

4 posts, 0 answers
  1. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 18 May 2014 Link to this post

    Hi,

    i use a Grid to Display a Datatable. I select the Data with an SQL-Statement. But how do i display the value from the inner join (second table)?

    DataTable Kommentare
        {
            get
            {
                if (Object.Equals(Session["Kommentare"], null))
                {
                    string query = "SELECT id, paketid, kommentar, bewertung, produkt FROM [kommentare] INNER JOIN [rating] ON kommentare.paketid = rating.id";
                    DataTable dt = GetDataTable(query);
                     
                    Session["Kommentare"] = dt;                               
                }
                return (DataTable)Session["Kommentare"];
            }
            set
            {
                Session["Kommentare"] = value;
            }
        }

    How do is diaply "produkt " which is a field from table "kommentare"?

    <telerik:GridBoundColumn AllowSorting="true" DataField="produkt" HeaderText="Produkt" SortExpression="Produkt" UniqueName="produkt"  />

    will not work!

    Thanks
    best Regards
    Rene
  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 May 2014 in reply to ITA Link to this post

    Hi,

    Please try the following query string for inner join, add TableName.ColumnName to display the columns in Grid.

    C#:
    string query = "SELECT kommentare.id, kommentare.paketid, . . . , rating.produkt FROM [kommentare] INNER JOIN [rating] ON kommentare.paketid = rating.id";

    Thanks,
    Princy
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 19 May 2014 in reply to Princy Link to this post

    Hi,

    i changed the SQL-String:

    string query = "SELECT kommentare.id, kommentare.paketid, kommentare.kommentar, kommentare.bewertung, rating.produkt FROM [kommentare] INNER JOIN [rating] ON kommentare.paketid = rating.id";

    and the aspx:
    <telerik:GridBoundColumn AllowSorting="true" DataField="rating.produkt" HeaderText="Produkt" SortExpression="Produkt" UniqueName="produkt"  />

    But without any success.

    Thanks
    Best Regards
    Rene
  5. ITA
    ITA avatar
    383 posts
    Member since:
    Aug 2009

    Posted 19 May 2014 in reply to ITA Link to this post

    Hi,

    solved, the Problem was the DataField="Rating.Produkt" - bettes ist DataField=Produkt".

    thanks for your Help
    Rene
Back to Top