Vikky
Vikky

Reputation: 764

Autofill username in Add data screen in lightswitch

I have a add data screen. There is a entity Username (which is foreign key refrence from user table). So Light-switch is showing auto-complete box. How can i restrict that only Current User-name is displayed. I have tried using find control and assign the value to Current user but it added blank in username.

 Private Sub AddWorkLog_Activated()

        Dim name As IContentItemProxy = Me.FindControl("Name")
        AddHandler name.ControlAvailable, AddressOf _name
    End Sub

 Private Sub _name(sender As Object, e As ControlAvailableEventArgs)
        Dim a As Object = e.Control

        a.text = Me.Application.User.Name.ToString()
        a.selectedItem.value = Me.Application.User.Name.ToString()


    End Sub

but i dont think it works here as what added to my table is id of that user. So how can i restrict this feild as per current user

Upvotes: 0

Views: 841

Answers (1)

Yann Duran
Yann Duran

Reputation: 3879

I think your approach is the wrong way around. Instead of trying to change the value of a screen control, simply assign the value of the current user to the property that the control is bound to. LightSwitch will take care of the rest.

Upvotes: 1

Related Questions