Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

default value on detailview insert mode

Status
Not open for further replies.

vcllvc

Programmer
Jul 12, 2001
136
US
I have a asp.net 2.0 detailView control, and I want to set a default value for the insert mode. I'd converted the row into a template row and set the textbox.text with a default value, however, when I hit the insert button, the page throw an exception.It says the value is null.

Does anyone know how to set a default value in detailview for the insert mode?
 
oh, sorry,

I converted the "Column" into a "template Column"

 
Try something like this:
Code:
Protected Sub DetailsView1_ItemCreated(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.ItemCreated
If DetailsView1.CurrentMode = DetailsViewMode.Insert Then
   Dim tb As New TextBox
   ''You need to know the correct index of the row.
   tb = CType(DetailsView1.Rows(1).FindControl("YourTextBox", TextBox)
   tb.Text = "Default Value"
End If
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top