C
Cas
Hi,
I use a detailsview control for inputtng data. I want to check the user
input before it is sent to the database (min. /max value, not empty, only
some values allowed ...). When clicking on the insertbutton, i want a
warning if one or more inputs are not correct and the user must have the
opportunity to correct his errors (so all the fields must remains as it).
I know it exists e.g. "RequiredFieldValidator", but i can't link it to a
detailsview.
I tried this, but here i only can limit the length of an input.
The fields are "fld1', 'fld2' etc ...till 'fld5'
Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles
DetailsView1.ItemInserting
Dim fld,valuefld(5) As String
Dim i, tel As Integer
For i = 1 To 5
valuefld(i) = e.Values("fld" & i)
tel=len(value1(i))
if tel>255 then
valuefld(i)=left(valuefld(i),255)
end if
next
SqlDataSource1.InsertCommand =="insert into data (fld1,fld2,fld3,fld4,fld5)
values ('" & valuefld(1) ....
SqlDataSource1.ProviderName = "System.Data.OleDb"
End Sub
Thansk for help
Cas
I use a detailsview control for inputtng data. I want to check the user
input before it is sent to the database (min. /max value, not empty, only
some values allowed ...). When clicking on the insertbutton, i want a
warning if one or more inputs are not correct and the user must have the
opportunity to correct his errors (so all the fields must remains as it).
I know it exists e.g. "RequiredFieldValidator", but i can't link it to a
detailsview.
I tried this, but here i only can limit the length of an input.
The fields are "fld1', 'fld2' etc ...till 'fld5'
Protected Sub DetailsView1_ItemInserting(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DetailsViewInsertEventArgs) Handles
DetailsView1.ItemInserting
Dim fld,valuefld(5) As String
Dim i, tel As Integer
For i = 1 To 5
valuefld(i) = e.Values("fld" & i)
tel=len(value1(i))
if tel>255 then
valuefld(i)=left(valuefld(i),255)
end if
next
SqlDataSource1.InsertCommand =="insert into data (fld1,fld2,fld3,fld4,fld5)
values ('" & valuefld(1) ....
SqlDataSource1.ProviderName = "System.Data.OleDb"
End Sub
Thansk for help
Cas