View Single Post
  #1 (permalink)  
Old November 1st, 2006, 06:49 PM
jpullam jpullam is offline
Authorized User
 
Join Date: Oct 2006
Location: Toronto, Ontario, Canada.
Posts: 20
Thanks: 1
Thanked 0 Times in 0 Posts
Default Setting a DetailsView Insert default value

I'm trying to do what would seem like a fairly straightforward thing: I am using a GridView/DetailsView combo and programmming it to insert a new record.

I'd like to specify default values for some fields so that when the user clicks on "New", it shows those values when the input form opens, but I can't figure out how to do it. There are many events and properties, but nothing I can manage to make work. I've found a few other queries like this on the net and the only suggestion was to use the ItemCreated event. That author tried to set the value with this statement

Ctype(DetailsView1.Rows(1).Cells(1).Controls(0), TextBox).Text= GridView1.SelectedRow.Cells(2).Text ===>>>??????

I don't understand it, it didn't work for me, and am surprised at how archaic coding row and column by number would be. In old ASP, I'd just place the default in the field before displaying it, and then get the user-entered value back after with objRS.

Is there anything like that in .Net?

For what its worth, my current version of the function call is

    Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, _
        ByVal e As EventArgs)
        If DetailsView1.CurrentMode = DetailsViewMode.Insert Then
        DetailsView1.Values("InsertName")="hello"
        End If
    End Sub


This of course doesn't work.

Reply With Quote