Visual Studio 2010中的LINQ C# [英] LINQ c# in visual studio 2010

查看:63
本文介绍了Visual Studio 2010中的LINQ C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我们有3条记录,其中有雇员ID,姓名和出生日期列..我们必须在这三个列中显示两个列..那么,如何使用C#代码在LINQ中插入LINQ代码,在网格视图中显示这两个列记录呢?它吗?

if we have 3 records with employeeID,name and dateofbirth coloumns..and we have to show two coloumns out of these three coloumns ..then how can you show these two coloumns records in grid view using c# code inserting LINQ code in it ?

推荐答案

我了解您的问题.

{
var r =来自ct.Emp(table)中的c
选择新的{c.EmpId,c.EmpName}

datagridview1.DataSource = r;
}
I Understand ur Question.

{
var r= from c in ct.Emp(table)
select new{c.EmpId,c.EmpName}

datagridview1.DataSource=r;
}


将数据放入GridView与您如何检索数据无关.您真正的问题是什么?
putting data into a GridView has nothing to do with how you retrieve the data. What''s your real question?


void fillCh()
{
    dgChofer.Rows.Clear();
    clasedetablasDataContext ct = new clasedetablasDataContext();
    var q = from c in ct.tblchofers
            select c;
    foreach (var x in q)
    {
        dgChofer.Rows.Add(x.idchofer.ToString(), x.nombreChofer, x.apellidoChofer, x.estadoChofer);
    }
}



希望对您有帮助!



i hope this help!!


这篇关于Visual Studio 2010中的LINQ C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆