TOP

Linq to SQL Combine two columns to make a readonly custom column

var rqSaleRepId = from m in db.RequestSaleReps select new { m.RequestSaleRepId, @RepNoWithName=m.SaleRepNo + ” – ” + m.Name};
ViewData["RequestSaleRepID"] = new SelectList(rqSaleRepId, “RequestSaleRepId”, “RepNoWithName”, editView.RequestSaleRepId);

<%= Html.DropDownList("RequestSaleRepId", (IEnumerable)ViewData["RequestSaleRepID"])%>

Read More
TOP

Insert, Update, and Delete Operations – LINQ to SQL

http://msdn.microsoft.com/en-us/library/bb386931.aspx

Northwnd db = new Northwnd(@”c:\Northwnd.mdf”);

// Query for a specific customer.
var cust =
(from c in db.Customers
where c.CustomerID == “ALFKI”
select c).First();

// Change the name of the contact.
cust.ContactName = “New Contact”;

// Create and add a new Order to the Orders collection.
Order ord = new Order { OrderDate = DateTime.Now };
cust.Orders.Add(ord);

// Delete an existing Order.
Order ord0 = cust.Orders[0];

// Removing it from the table also removes it from the Customer’s list.
db.Orders.DeleteOnSubmit(ord0);

// Ask the DataContext to save all the changes.
db.SubmitChanges();

Read More
TOP

ASP.net MVC Strongly Typed Html Helpers

http://weblogs.asp.net/scottgu/archive/2010/01/10/asp-net-mvc-2-strongly-typed-html-helpers.aspx

Read More

Switch to our mobile site