asp.net - Setting Values for Invisible Fields/Properties in DetailsView -


I have a description view that has two fields - which is not visible, it is not. User first fills, second I want to auto populate. Unfortunately, I can not find a way to set the value in this second invisible field. I have tried to add code to Page_load in this way:

  If not, then it is the Istobac description then View 1. Default mode = DetailsViewModel.example.txt text box = DirectCast (DescriptionView 1.Find control ("type"), text box) Txt1.Text = "administrator" end if   

but this "object reference Returns an error not set for an instance of an object. " Any ideas about how to accomplish this - either on the method or using any other method?

The end result is expected to be that when a new record is inserted through a description view, then this record is registered with the user name (user) as well as the "type" of "administrator" < / Div>

You should set the style of style Control:

  style = "visibility: hidden; Height: 0 "  

The browser will not show them in this way.

If you set the control on the server to invisible, no HTML will be provided.

Edit: You can also use a hidden field:

  & lt; Asp: HiddenField runat = server value = "some value" />   

However, to keep information on the server, the session variable may be better or in some cases the information can be processed in the hidden areas of the customer).

Comments