Setting Default Values in a DetailsView

D

David H

I'm trying to set default values for a couple of fields in a DetailsView. The
event below successfully fires and while it appears visually that the values
are being set (the text boxes are not displayed), they actually aren't. The
INSERT craps out indicating that a value wasn't supplied and the record can't
be added. (Some of the fields in the database do not allow NULL.) Given that
this would be my first attempt at any ASP.NET code, I'm assuming the issue is
with the .Cells property.

So my questions is how do I set the values?

Sub ChangeNotice_ItemCreated(ByVal sender As Object, ByVal e As EventArgs)

Dim gv_ShowList As gridView
Dim gvr_ShowList As gridViewRow
Dim dv_ChangeNotice As DetailsView

If Not isPostBack Then
If ChangeNotice_DetailsView.CurrentMode = DetailsViewMode.Insert
Then
gv_ShowList = PreviousPage.FindControl("gridView_ShowList")
gvr_ShowList = gv_ShowList.SelectedRow
dv_ChangeNotice = Page.FindControl("ChangeNotice_DetailsView")
dv_ChangeNotice.Rows(0).Cells(1).text =
gvr_ShowList.Cells(1).text
dv_ChangeNotice.Rows(2).Cells(1).text = "New"
dv_ChangeNotice.Rows(3).Cells(1).text = Now
dv_ChangeNotice.Rows(4).Cells(1).text = ""
dv_ChangeNotice.Rows(5).Cells(1).text = ""
dv_ChangeNotice.Rows(6).Cells(1).text = ""
End If
End If
End Sub
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top