{"id":230,"date":"2012-09-21T11:56:42","date_gmt":"2012-09-21T11:56:42","guid":{"rendered":"http:\/\/ntspl.co.in\/blog\/?p=230"},"modified":"2024-09-18T10:47:05","modified_gmt":"2024-09-18T10:47:05","slug":"fill-gridview-using-linq","status":"publish","type":"post","link":"https:\/\/www.ntspl.co.in\/blog\/fill-gridview-using-linq\/","title":{"rendered":"Fill Gridview Using LINQ"},"content":{"rendered":"<p><strong>1.Take object of linq sql<\/strong><\/p>\n<pre class=\"code-structure\"><code>sewakdbDataContext swdb = new sewakdbDataContext();<\/code><\/pre>\n<p><strong>2.Create object of table<\/strong><\/p>\n<pre class=\"code-structure\"><code>tblEvents tblevent = new tblEvents();<\/code><\/pre>\n<p><strong>3.Create a function for grid<\/strong><\/p>\n<pre class=\"code-structure\"><code>private void _LoadGrid() {\r\n\r\n\tvar v = (from d in swdb.tblEvents where d.ARCHIVE_STATUS ==false select d).ToList();\r\n\r\n\tv = v.Where(d =&gt; d.EV_PURPOSE.StartsWith(txtdesc.Text == null ? string.Empty : txtdesc.Text)).ToList();\r\n\r\n\tv = v.Where(d =&gt; d.EV_TITLE.StartsWith(txttitle.Text == null ? string.Empty : txttitle.Text)).ToList();\r\n\r\n\tv = v.Where(d =&gt; d.EV_PLACE.StartsWith(txtPlace.Text == null ? string.Empty : txtPlace.Text)).ToList();\r\n\r\n\tif(txtFromDate.Text!=string.Empty)\r\n\r\n\tv = v.Where(d =&gt; d.EV_DATE_FROM==Convert.ToDateTime(txtFromDate.Text.Trim())).ToList();\r\n\r\n\tif (txtTo.Text != string.Empty)\r\n\r\n\tv = v.Where(d =&gt; d.EV_DATE_TO == Convert.ToDateTime(txtTo.Text.Trim())).ToList();\r\n\r\n\tv = v.Where(d =&gt; d.EV_HOSTED_BY.StartsWith(txtHostedBy.Text == null ? string.Empty : txtHostedBy.Text)).ToList();\r\n\r\n\tgvevents.DataSource = v;\r\n\r\n\tgvevents.DataBind();\r\n\r\n}<\/code><\/pre>\n<p>you can use this function for search.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1.Take object of linq sql sewakdbDataContext swdb = new sewakdbDataContext(); 2.Create object of table tblEvents tblevent = new tblEvents(); 3.Create a function for grid private void _LoadGrid() { var v = (from d in swdb.tblEvents where d.ARCHIVE_STATUS ==false select d).ToList(); v = v.Where(d =&gt; d.EV_PURPOSE.StartsWith(txtdesc.Text == null ? string.Empty : txtdesc.Text)).ToList(); v = v.Where(d =&gt; [&hellip;]<\/p>\n","protected":false},"author":18,"featured_media":1605,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3,30,32],"tags":[147,214],"class_list":["post-230","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-asp-dot-net","category-sql-server","category-tutorials","tag-girdview-with-linq","tag-linq-with-grid"],"acf":{"custom_meta_title":"Fill Gridview Using LINQ to SQL | NTSPL","meta_description":"Do you know how to create a gridview using LINQ to SQL? Read the easy and step by step article to know Fill Gridview using LINQ to SQL.","meta_keyword":"gridview using linq, gridview using linq to sql","other_meta_tag":"<meta property=og:locale content=\"en-IN\" \/>\r\n<meta property=og:type content=\"website\" \/>\r\n<meta property=og:title content=\"Fill Gridview Using LINQ to SQL | NTSPL\"\/>\r\n<meta property=og:description content=\"Do you know how to create a gridview using LINQ to SQL? Read the easy and step by step article to know Fill Gridview using LINQ to SQL.\"\/>\r\n<meta property=og:url content=\"https:\/\/www.ntspl.co.in\/blog\/fill-gridview-using-linq\"\/>\r\n<meta property=\"og:image\" content=\"https:\/\/www.ntspl.co.in\/blog\/fill-gridview-using-linq\/\"\/>\r\n<meta property=og:site_name content=NTSPL \/>\r\n<meta name=\"twitter:site\" content=\"@NTSPL\">\r\n<meta name=twitter:card content=\"summary\" \/>\r\n<meta name=twitter:description content=\"Do you know how to create a gridview using LINQ to SQL? Read the easy and step by step article to know Fill Gridview using LINQ to SQL.\"\/>\r\n<meta name=twitter:title content=\"Fill Gridview Using LINQ to SQL | NTSPL\"\/>"},"_links":{"self":[{"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/posts\/230"}],"collection":[{"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/comments?post=230"}],"version-history":[{"count":4,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/posts\/230\/revisions"}],"predecessor-version":[{"id":10578,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/posts\/230\/revisions\/10578"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/media\/1605"}],"wp:attachment":[{"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/media?parent=230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/categories?post=230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ntspl.co.in\/blog\/wp-json\/wp\/v2\/tags?post=230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}