?
Solved

linq load data to label

Posted on 2014-07-22
3
Medium Priority
?
263 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:Seven price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 63

Accepted Solution

by:
Fernando Soto earned 2000 total points
ID: 40212605
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:Seven price
ID: 40212650
love it. Thanks
0
 
LVL 63

Expert Comment

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

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

800 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