开发者

select multi column from stored procedures form dataGridview

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜