C#

by Dave Mon 11 February 2008 @ 10:47

LINQ is awesome!

   1: // Get the data from the database using LINQ
   2: var topTen =
   3:   (from bl in lpcsql.Blogs
   4:   where bl.PostType == 1
   5:   orderby bl.ID descending
   6:   select bl).Take(10);
   7: // Bind data to the repeater.
   8: objBlog.DataSource = topTen;
   9: objBlog.DataBind();
  10: // Check if its me, and if so activate the Edit and Delete controls
  11: if (User.IsInRole("Administrators"))
  12: {
  13:   for (int post=0; post < objBlog.Items.Count; post++)
  14:   {    Label lbl = (Label)objBlog.Items[post].FindControl("EditControl");
  15:     if (lbl.Visible == false)
  16:       lbl.Visible = true;
  17:     if (lbl.Enabled == false)
  18:       lbl.Enabled=true;
  19:   }
  20: }
  21: lpcsql.Connection.Close(); 

Categorised : Building, Programming
Tagged with : ,


Add comment




  Country flag
biuquote
  • Comment
  • Preview
Loading


Johann Sebastian Bach's grave is here, along with the organ whose construction he advised on. Pretty awesome tbh :-)This is where US and Soviet forces met for the first time in world war two.Awesome awesome view from a restaurant on top of the Bastei!We had lunch in Meissen at the cafe in the famous porcelain factory, and ate from about €1000 worth of chinaA little light lunch and some wine...Dresden's famous frauenkirche, recently rebuilt after being destroyed in the second world war.