Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 14th, 2007, 01:26 AM
Authorized User
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default How to check for null primary key value?

Is there a code ib VB or Design phase that I can check for any null inputs for primary key fields (DetailsView) before submitting into the database?
 
Old August 14th, 2007, 02:45 AM
Registered User
 
Join Date: Aug 2007
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Can u be more clear


Archu
 
Old August 14th, 2007, 03:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

Are you using validation-controls?

 
Old August 14th, 2007, 04:05 AM
Authorized User
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default

I apologise for not being clear.

Okays, I'm using Visual Web Developer 2005 Express Edition, MS Access, AccessDataSource control. To view, edit, or insert entry, I'm using the DetailsView control in-built from the Visual Web Developer. I've tried the intellisense by typing "DetailsView1." to hope and try get the parameter for the textbox in DetailsView holding the promary key when I insert the value. However, I couldn't find it. It there any VB codes or and asp.net codes that could check whether this particular textbox(in-built from DetailsView provided by Visual Web Developer) is empty before or after I click "Insert" hyperlink(again in-built from DetailsView provided by Visual Web Developer), so that I do not end up with an error?

I have used the Validation controls before, is there anything like Validation that I can use on this in-built DetailsView to check on that particular textbox? Validation control's RequiredFieldValidation do not work on DetailsView.

Thank you
 
Old August 14th, 2007, 07:17 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

why can you just add the validation control to the detailsview???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old August 14th, 2007, 07:28 AM
Authorized User
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default

I've tried it, however the RequiredFieldValidation's ControlToValidate doesn't work on DetailsView. Is there others that can work on DetailsView?
 
Old August 14th, 2007, 09:18 PM
Authorized User
 
Join Date: Aug 2007
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to yukijocelyn
Default

Hey guys! I found the answer! Thank you so much for guiding me through, thought I'll post here to benefit others who might have the same problems as I had.

http://msdn2.microsoft.com/en-us/lib...es(VS.80).aspx

<%@ Page language="VB" autoeventwireup="false" %>

<script runat="server">

  Sub CustomerDetailsView_ItemInserting(ByVal sender As Object, _
    ByVal e As DetailsViewInsertEventArgs) _
    Handles CustomerDetailsView.ItemInserting

    ' Use the Values property to retrieve the key field value.
    Dim keyValue As String = e.Values("CustomerID").ToString()

    ' Insert the record only if the key field is four characters
    ' long; otherwise, cancel the insert operation.
    If keyValue.Length = 4 Then

      ' Change the key field value to upper case before inserting
      ' the record in the data source.
      e.Values("CustomerID") = keyValue.ToUpper()

      MessageLabel.Text = ""

    Else

      MessageLabel.Text = "The key field must have four digits."
      e.Cancel = True

    End If

  End Sub

</script>





Similar Threads
Thread Thread Starter Forum Replies Last Post
Foreign key not updating with Primary key xavier1945 BOOK: Access 2003 VBA Programmer's Reference 2 July 4th, 2007 09:48 PM
<bean:message key="PNR.INPUT"/> key has null value warsha_14 Struts 1 November 13th, 2006 07:26 AM
FOREIGN KEY and PRIMARY KEY Constraints junemo Oracle 10 June 15th, 2004 01:00 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.