Solved

linq load data to label

Posted on 2014-07-22
3
249 Views
Last Modified: 2016-02-15
Yes I want to load about 10 rows of data. 3.5 frame c#

  DataContext db = new DataContext();

 var AptTrans = from value in
                               (from data in db.Types
                                orderby data.urityTypeID descending
                                select new
                                {
                                    TypeID = data.TypeID,
                                    TypeName = data.TypeName

                                })
                           group value by value.TypeID into c
                              select c.Distinct();

loadTypes = '<table>';
loadTypes += '<tr><td>' + TypeID + '</td><td>' + TypeName + '</td></tr>;
loadTypes = '</table>;


<asp:label runat=server id="loadTypes" />

Open in new window

0
Comment
Question by:sevensnake77
  • 2
3 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
Comment Utility
Hi sevensnake77;

The following code snippet should format the result of the query for the Label control

using System.Text;
                  
                             
StringBuilder sb = new StringBuilder();                                                    
                                                              
foreach (var grouping in AptTrans)                                   
{                                                             
    foreach (var element in grouping)                                
    {                                                         
        sb.Append(element.TypeID + "\t " + element.TypeName + "\n");
    }                                                         
}

Open in new window

Now all you need to do is bind the sb, StringBuilder, to the Label control with sb.ToString().
0
 
LVL 9

Author Closing Comment

by:sevensnake77
Comment Utility
love it. Thanks
0
 
LVL 62

Expert Comment

by:Fernando Soto
Comment Utility
Not a problem sevensnake77, glad I was able to help.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now