|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to set default values for fields in detailsviewHi,
How to set the default values for fields in detailsview in INSERT mode? Which event should I use? By default the fields are blank in insert mode. Any help is appreciated. Thanks I would use the ItemCreated event. For example, if we were to build on this
QuickStart tutorial to copy the selected row values on the GridView as the default for the newly inserted record: http://www.asp.net/QuickStart/aspnet/doc/ctrlref/data/detailsview.aspx I would write: Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, _ ByVal e As EventArgs) 'execute the following only when inserting a new record If DetailsView1.CurrentMode = DetailsViewMode.Insert Then 'each row corresponds to a BoundField on the DetailsView definition 'Row(1) is the second field: the au_lname field 'when it renders in insert mode, it renders a cell that has a 'textbox in it. We want to set the textbox.text property to 'the au_lname from the selected row on the GridView Ctype(DetailsView1.Rows(1).Cells(1).Controls(0), TextBox).Text= _ GridView1.SelectedRow.Cells(2).Text 'continue to set the other textboxes on the record to be 'inserted using the same process End If End Sub Show quoteHide quote "mt" wrote: > Hi, > > How to set the default values for fields in detailsview in INSERT mode? > Which event should I use? By default the fields are blank in insert mode. > > > Any help is appreciated. > > Thanks >
Other interesting topics
One page - edit & insert
return url value Show ***** only if have a password Display a record - several questions How do I debug apsx pages? Validation inside composite controls for ASP .NET 2.0 using 'sender' object on event fires FormView - initial template problem traping event in child control must click button twice for event to fire |
|||||||||||||||||||||||