Get data using LINQ and show result in a gridview

后端 未结 3 1467
陌清茗
陌清茗 2021-01-27 04:25

How can I get all modules from the array like below where student firstName, using Linq in C# and Asp.net. It\'s something probably easy to do but have failed to get the trick.

3条回答
  •  心在旅途
    2021-01-27 04:30

    you are missing ToList at the end of your query.

    yourGridView.DataSource = (from Student s in arrList
                        where s.FirstName == "Cesar"
                        select s).ToList();
    

    then bind it to your gridview.

提交回复
热议问题