Preset fields in detailsview.

A

Alan Morris

I am trying to preset some values on a detailsview for inserting a
record. If I try:-

DetailsView1.Rows(0).Cells(1).Text = "My text2"

then the text looks like a label and is not editable - not in the
textbox of the field concerned. Am I right in thinking I have to
'cast' the boundfield in some way.

I am rather baffled by this.

Any help appreciated.

Alan
 
P

Phil H

Hi Alan

I don't know of any way to pre-enter them in the text boxes but if what
you are trying to do is create some default values then you can specify
them by configuring the INSERT command of the SqlDataSource.

Use the Propeties window for the DataSource not the "Configure
DataSource" wizard. You'll be able to link the parameters to the
DetailsView control and specify default values.

One way you could indicate default values to the user is to edit the
Head text of the field something like this:

First name (Fred)
Last name (Blogs)
 
P

Phil H

Hi Again Alan

A further thought. You might consider using a FormView rather than a
DetailsView for entering new records. Its all based on templates and
you'll have more control over the appearance in different modes.
 
A

Alan Morris

Phil,

Thanks your reply, what I am trying to do is create a data entry form,
where certain fields will be common from one record to the next. Thus
to save the user retyping everything I was planning to catch the
relevant fields from the previous submit and use these values to
populate the form.

Hope that makes sense.

Regards,
 
A

Alan Morris

Phil,

Thanks your further reply, I researched your idea of a FormView and
came up with some suggestions on the web of how to achieve what I
wanted with such. I was then able to apply these to the details view
in the following way:-

I converted the relevant fiellds of the DetailsView to Template items
and then set the value of each of these as follows:-

DirectCast(Me.DetailsView1.FindControl("TextBox1"), TextBox).Text =
expression.

Thanks again.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top