Hi Friends,
I want to show the data in gridview through the Linq data source, how can we do this ?
Show data in GridView Through Linq
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Satyapriya NayakRank #47 · 31.5K reputationPosted May 25, 2012, 9:14 PM EDT
Please refer the below link
http://www.codeproject.com/Articles/33685/Simple-GridView-Binding-using-LINQ-to-SQL
Thanks
Ajay Patel148 reputationPosted May 31, 2012, 10:54 PM EDT
var countryList = (from country in objEntity.Countries
where country.flg_Deleted == false
orderby country.CountryName
select new
{
Country_ID = country.CountryID,
Country_Name = country.CountryName,
Country_Code = country.CountryCode,
Status = country.flg_Active.Value == true ? "Active" : "DeActive",
ISDCode = country.ISDCode
});
Grid.dataSource = countryList;
Grid.Databind();
Grid Column's Data Field Must be same as Column Name Here. Like Country_ID.Country_Name..