开发者

select multi column from stored procedures form dataGridview

开发者 https://www.devze.com 2023-02-12 21:04 出处:网络
sto开发者_如何学JAVAred procedures as follows : Create Procedure tblProfile_SelectAll As Begin Select

sto开发者_如何学JAVAred procedures as follows :

    Create Procedure tblProfile_SelectAll
As
Begin
    Select 
        [name],
        [family]
    From tblProfile
End

I'm working with LinqToSql

The following code shows all fields.

    using (var c = new contextDataContext())
    {
        var query = c.tblProfile_SelectAll();
        dataGridView1.DataSource = query.ToList();
    }

How to display only the name field?

Without changing the stored procedures


Just edit the design time properties of the DataGridView. Set AutoGenerateColumns to false and add a single text column for name.


I would try

dataGridView1.DataSource = query.Select(q => new {name = q.name}).ToList();
0

精彩评论

暂无评论...
验证码 换一张
取 消