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();
精彩评论