0
使用ASP.NET 4.0LINQ - 選擇新建 - 包括列表框中選定項
我有對LINQ惹上麻煩的.srvc_id是檢查的值和我下面的查詢只用於填充第一個複選框我的對象。
代碼
If Not IsNothing(lbServices.SelectedItem) Then
'NEW record INSERT values from list box to table.
myServices = (From item In lbServices.Items
Where item.Selected
Select New tbl_parent_to_child With
{
.id = myServices.child_id,
----- .srvc_id is where I am stuck any help would be great. It is repeating the first selected check box.
.srvc_id = lbServices.SelectedValue,
.Active = True,
.CreateDate = DateTime.Now,
.CreateByID = SecurityMethods.GetLoginUserId(Session("AuthUser")),
.UpdateDate = DateTime.Now,
.UpdateByID = SecurityMethods.GetLoginUserId(Session("AuthUser"))
}).ToList()
For Each item In myServices
ctx.tbl_parent_to_child .Add(item)
Next
End If
Try
ctx.SaveChanges()
Catch ex As Exception
Me.Master.HandleStatusMessageEvent((New StatusMessageEventArgs("Email a screen shot of this error to the Help Desk", StatusMessageType.ErrorMsg)))
End Try