LINQ to SQL Setting ComboBox Settings

Hi,

I am new to LINQ and I am trying to get a couple of things for my project to work. I have a ComboBox that I want to set the display member of with LINQ and I can't seem to find any way or example on how to do it.

Can someone please help me.

Thanks

[611 byte] By [Lawrence007] at [2008-1-8]
# 1

Hi,

This is a good post on UI binding in ASP.net - http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx

The main thing is to set the DataValueField and the DataTextField.

Code Snippet

NorthwindDataContext db = new NorthwindDataContext();

DropDownList1.DataValueField = "OrderID";

DropDownList1.DataTextField = "OrderDate";

DropDownList1.DataSource = from o in db.Orders

select new { o.OrderID, o.OrderDate };

DropDownList1.DataBind();

Hope this is ok for you, any more questions please let me know.

Ben

ben2004uk at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...
# 2
Again, Thanks Ben
Lawrence007 at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...

Visual Studio Orcas

Site Classified