inserting and validating data

krraleigh

New member
Joined
Dec 6, 2008
Messages
3
Programming Experience
Beginner
I am working from a tutorial that shows me how to use the details view to insert data to ms access, but I need to use the validation controls to ensure that the data is the correct type.

Now the book showed me how to use the validation controls on the text boxes etc, but said nothing about validating data using the controls.

So is it possible to validate the data when using the controls such as the details view?

Is there another way to do the inserting so that I can validate my data?

VB.NET:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="addDiv_Prog_Chur.aspx.vb" Inherits="addDiv_Prog_Chur" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CCSCC</title>
<link rel="stylesheet" type="text/css" href="contact.css" />

<script language="JavaScript">
function openDir( form ) { 
	var newIndex = form.dropMenu.selectedIndex; 
	if ( newIndex == 0 ) { 
		alert( "Please select a location!" );
	} else { 
		cururl = form.dropMenu.options[ newIndex ].value; 

		window.location.assign( cururl ); 
	} 
} 
function addProgram_onclick() {

}

</script>

</head>

<body>
	
	<form name="frmDivision" runat="server">  
<div name="dropMenu" class="dropMenu">
 
 <select name="dropMenu" size="1" onChange="openDir( this.form )"> 
	<option>Choose Webpage</option>
	<option value="home.html">Home</option>
	<option value="index.html">Search</option>
	<option value="addDiv.aspx">Add Division</option>
	<option value="addContact.html">Add Contact</option>
	<option value="addEvents.html">Add Events</option>
	<option value="addMeetings.html">Add Meetings</option>
	<option value="addCourses.html">Add Courses</option>
	<option value="addServices.html">Add Services</option>
	<option value="addProjects.html">Add Projects</option>
	<option value="addDiv_Prog_Chur.html">Add Div-Proj-Church</option>
	</select> 
</div>
    <asp:AccessDataSource ID="divName" runat="server" 
        DataFile="~/database/ccscc.mdb" 
        DeleteCommand="DELETE FROM [Division] WHERE [divId] = ?" 
        InsertCommand="INSERT INTO [Division] ([divName]) VALUES (?)" 
        SelectCommand="SELECT * FROM [Division]" 
        UpdateCommand="UPDATE [Division] SET [divName] = ? WHERE [divId] = ?">
        <DeleteParameters>
            <asp:Parameter Name="divId" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="divName" Type="String" />
            
        </UpdateParameters>
        <InsertParameters>
            
            <asp:Parameter Name="divName" Type="String" />
        </InsertParameters>
    </asp:AccessDataSource>
<div class="topParent">
	<div class="parentAddDiv_Prog_Chur">	
	<img src="blueBanner.jpg" alt="banner catholic charities" />	
	<h1 align="center">Add Divisons</h1>
	<div class="formWrapper">	
		<fieldset>  
			<legend>Add Division</legend>  
			<ol>			
			  <li>
			    <label for="division">Division</label> Name
			      <asp:DetailsView ID="DetailsView4" runat="server" AutoGenerateRows="False" 
                      DataKeyNames="divId" DataSourceID="divName" Height="50px" Width="125px">
                      <Fields>
                          <asp:BoundField DataField="divName" SortExpression="divName" />
                          <asp:CommandField ShowInsertButton="True" ButtonType="Button" 
                              InsertText="Insert Division Name" />
                      </Fields>
                  </asp:DetailsView>
			 </li>
                </ol>			    
		</fieldset>
	  </div> 
	</div>	
</div>

	</form>
	  
</body>
</html>
Kevin:)
 
figured it out

sorry for wasting space I converted the item to a template field and was able to do what I needed. Very easy.

sorry for the wasted space

Kevin
 
I am having a similar issue

I have a template field and a CustomValidator control to validate that a proper time was entered but I am having trouble with the function in the code behind file.

This is what I have
Protected Sub CustomValidator1_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs)


args.IsValid = True


If Not IsDate(args.Value) Then
args.IsValid = False
Exit Sub
End If

If Format(args.Value, "General Number") <= 1 Then args.IsValid = "false"

End Sub

It doesn't work even if a proper time is entered.
Can you help?
Thanks
 
Back
Top