Question : SQL Statement is displayed instead of data

My gridview EVAL statement is returned the T-SQL statment("SELECT [t1].[Name] FROM [dbo].[PackedOrder] AS [t0] INNER JOIN [dbo].[ShippingID] AS [t1] ON [t0].[OrderNum] = @p0 ") instead of the value, below is asp code; and function which uses a linq stement to fetch the name from a foreign key table.


<ItemTemplate>
    <asp:Label ID="ShipperLabel" runat="server" Text='<%# GetShipperName(Eval("OrderNum")) %>'  />
</ItemTemplate>





public string GetShipperName(object order)
        {
            ShippingDataContext db = new ShippingDataContext();

            var selorder = from o in db.PackedOrders
                           join name in db.ShippingIDs
                               on o.OrderNum equals order
                           select new { name.Name };

            return selorder.ToString();
        }

Answer : SQL Statement is displayed instead of data

Here is a good example of it and yes you should probably return List<string>. If you are wanting just one string, then in the foreach just concatenate the values together with a delimiter of some sort and return the final string.

http://blog.linqexchange.com/index.php/using-linq-to-convert-an-ienumerable-to-a-list/
Random Solutions  
 
programming4us programming4us