2014-01-30 3 views
0

Использования ASP.NET 4.0LINQ - выбрать новый - Включить ListBox Выбранных элементов

У меня возникли проблемы с 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 

ответ

Смежные вопросы