• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 414
  • Last Modified:

How do you update the value of a agetextbox in a ASP.net 2.0 formview with a calculated age using VB.net

I have two text boxes in my asp.net formview.  Birthday and AGE.  I want to calculate the age whenever a DOB is entered in the Birthday field and auto fill the AGE textbox with the calculated age.  Any assistance is greatly appreciated
0
pgkdavefdd
Asked:
pgkdavefdd
  • 3
  • 2
1 Solution
 
BTosonCommented:
Hi,
Try this:
Dim BirthdayDate As DateTime
If IsDate(Birthday.Text) AndAlso DateTime.TryParse(Birthday.Text, BirthdayDate) Then
	 Age.Text = DateDiff(DateInterval.Year, BirthdayDate, Now)
End If

Open in new window

0
 
AswinKrishnanCommented:
you can use javascript and specify the script to get triggered on 'onblur' of the Birthday textbox  and fill the corresponding value in age textbox.
0
 
pgkdavefddAuthor Commented:
BToson,  I have no problem doing it in VB6.  However this is my first time tring something like this in ASP.net.   So this is going to sound a little dumb but where do I put the code you suggested?  Attached is a my source code for the asp.net form with the form view.  
<%@ Page Language="VB" MasterPageFile="~/Default.master" Title="Untitled Page" %>
 
<script runat="server">
 
Protected Sub FormView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs)
        Response.Redirect("~/Council/Knights.aspx")
    End Sub
 
    Protected Sub birthdayTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
 
    End Sub
</script>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:FormView ID="FormView1" runat="server" DataKeyNames="pkid" DataSourceID="SqlDataSource1" DefaultMode="Insert" OnItemInserted="FormView1_ItemInserted">
        <EditItemTemplate>
            pkid:
            <asp:Label ID="pkidLabel1" runat="server" Text='<%# Eval("pkid") %>'></asp:Label><br />
            membernum:
            <asp:TextBox ID="membernumTextBox" runat="server" Text='<%# Bind("membernum") %>'>
            </asp:TextBox><br />
            prefix:
            <asp:TextBox ID="prefixTextBox" runat="server" Text='<%# Bind("prefix") %>'>
            </asp:TextBox><br />
            firstname:
            <asp:TextBox ID="firstnameTextBox" runat="server" Text='<%# Bind("firstname") %>'>
            </asp:TextBox><br />
            mi:
            <asp:TextBox ID="miTextBox" runat="server" Text='<%# Bind("mi") %>'>
            </asp:TextBox><br />
            lastname:
            <asp:TextBox ID="lastnameTextBox" runat="server" Text='<%# Bind("lastname") %>'>
            </asp:TextBox><br />
            suffix:
            <asp:TextBox ID="suffixTextBox" runat="server" Text='<%# Bind("suffix") %>'>
            </asp:TextBox><br />
            name:
            <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>'>
            </asp:TextBox><br />
            address1:
            <asp:TextBox ID="address1TextBox" runat="server" Text='<%# Bind("address1") %>'>
            </asp:TextBox><br />
            address2:
            <asp:TextBox ID="address2TextBox" runat="server" Text='<%# Bind("address2") %>'>
            </asp:TextBox><br />
            city:
            <asp:TextBox ID="cityTextBox" runat="server" Text='<%# Bind("city") %>'>
            </asp:TextBox><br />
            state:
            <asp:TextBox ID="stateTextBox" runat="server" Text='<%# Bind("state") %>'>
            </asp:TextBox><br />
            postalcd:
            <asp:TextBox ID="postalcdTextBox" runat="server" Text='<%# Bind("postalcd") %>'>
            </asp:TextBox><br />
            homephone:
            <asp:TextBox ID="homephoneTextBox" runat="server" Text='<%# Bind("homephone") %>'>
            </asp:TextBox><br />
            homeac:
            <asp:TextBox ID="homeacTextBox" runat="server" Text='<%# Bind("homeac") %>'>
            </asp:TextBox><br />
            altphone:
            <asp:TextBox ID="altphoneTextBox" runat="server" Text='<%# Bind("altphone") %>'>
            </asp:TextBox><br />
            altac:
            <asp:TextBox ID="altacTextBox" runat="server" Text='<%# Bind("altac") %>'>
            </asp:TextBox><br />
            alttype:
            <asp:TextBox ID="alttypeTextBox" runat="server" Text='<%# Bind("alttype") %>'>
            </asp:TextBox><br />
            ssn:
            <asp:TextBox ID="ssnTextBox" runat="server" Text='<%# Bind("ssn") %>'>
            </asp:TextBox><br />
            birthday:
            <asp:TextBox ID="birthdayTextBox" runat="server" Text='<%# Bind("birthday") %>'>
            </asp:TextBox><br />
            bmonth:
            <asp:TextBox ID="bmonthTextBox" runat="server" Text='<%# Bind("bmonth") %>'>
            </asp:TextBox><br />
            deceaseddt:
            <asp:TextBox ID="deceaseddtTextBox" runat="server" Text='<%# Bind("deceaseddt") %>'>
            </asp:TextBox><br />
            age:
            <asp:TextBox ID="ageTextBox" runat="server" Text='<%# Bind("age") %>'>
            </asp:TextBox><br />
            type:
            <asp:TextBox ID="typeTextBox" runat="server" Text='<%# Bind("type") %>'>
            </asp:TextBox>
            <br />
            class:
            <asp:TextBox ID="classTextBox" runat="server" Text='<%# Bind("class") %>'>
            </asp:TextBox><br />
            annualdues:
            <asp:TextBox ID="annualduesTextBox" runat="server" Text='<%# Bind("annualdues") %>'>
            </asp:TextBox><br />
            marital:
            <asp:TextBox ID="maritalTextBox" runat="server" Text='<%# Bind("marital") %>'>
            </asp:TextBox><br />
            parish:
            <asp:TextBox ID="parishTextBox" runat="server" Text='<%# Bind("parish") %>'>
            </asp:TextBox><br />
            fourth:
            <asp:CheckBox ID="fourthCheckBox" runat="server" Checked='<%# Bind("fourth") %>' /><br />
            assemblynm:
            <asp:TextBox ID="assemblynmTextBox" runat="server" Text='<%# Bind("assemblynm") %>'>
            </asp:TextBox><br />
            firstdeg:
            <asp:TextBox ID="firstdegTextBox" runat="server" Text='<%# Bind("firstdeg") %>'>
            </asp:TextBox><br />
            seconddeg:
            <asp:TextBox ID="seconddegTextBox" runat="server" Text='<%# Bind("seconddeg") %>'>
            </asp:TextBox><br />
            thirddeg:
            <asp:TextBox ID="thirddegTextBox" runat="server" Text='<%# Bind("thirddeg") %>'>
            </asp:TextBox><br />
            fourthdeg:
            <asp:TextBox ID="fourthdegTextBox" runat="server" Text='<%# Bind("fourthdeg") %>'>
            </asp:TextBox><br />
            degree:
            <asp:TextBox ID="degreeTextBox" runat="server" Text='<%# Bind("degree") %>'>
            </asp:TextBox><br />
            senddegnot:
            <asp:TextBox ID="senddegnotTextBox" runat="server" Text='<%# Bind("senddegnot") %>'>
            </asp:TextBox><br />
            office:
            <asp:TextBox ID="officeTextBox" runat="server" Text='<%# Bind("office") %>'>
            </asp:TextBox><br />
            offnum:
            <asp:TextBox ID="offnumTextBox" runat="server" Text='<%# Bind("offnum") %>'>
            </asp:TextBox><br />
            fratyear:
            <asp:TextBox ID="fratyearTextBox" runat="server" Text='<%# Bind("fratyear") %>'>
            </asp:TextBox><br />
            billmessg1:
            <asp:TextBox ID="billmessg1TextBox" runat="server" Text='<%# Bind("billmessg1") %>'>
            </asp:TextBox><br />
            billmessg2:
            <asp:TextBox ID="billmessg2TextBox" runat="server" Text='<%# Bind("billmessg2") %>'>
            </asp:TextBox><br />
            billstatus:
            <asp:TextBox ID="billstatusTextBox" runat="server" Text='<%# Bind("billstatus") %>'>
            </asp:TextBox><br />
            bstatdate:
            <asp:TextBox ID="bstatdateTextBox" runat="server" Text='<%# Bind("bstatdate") %>'>
            </asp:TextBox><br />
            retcommdt:
            <asp:TextBox ID="retcommdtTextBox" runat="server" Text='<%# Bind("retcommdt") %>'>
            </asp:TextBox><br />
            former_sqr:
            <asp:CheckBox ID="former_sqrCheckBox" runat="server" Checked='<%# Bind("former_sqr") %>' /><br />
            Email:
            <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>'>
            </asp:TextBox><br />
            paystat:
            <asp:TextBox ID="paystatTextBox" runat="server" Text='<%# Bind("paystat") %>'>
            </asp:TextBox><br />
            nobill:
            <asp:CheckBox ID="nobillCheckBox" runat="server" Checked='<%# Bind("nobill") %>' /><br />
            dead:
            <asp:CheckBox ID="deadCheckBox" runat="server" Checked='<%# Bind("dead") %>' /><br />
            duespaid:
            <asp:CheckBox ID="duespaidCheckBox" runat="server" Checked='<%# Bind("duespaid") %>' /><br />
            paidthru:
            <asp:TextBox ID="paidthruTextBox" runat="server" Text='<%# Bind("paidthru") %>'>
            </asp:TextBox><br />
            balancedue:
            <asp:TextBox ID="balancedueTextBox" runat="server" Text='<%# Bind("balancedue") %>'>
            </asp:TextBox><br />
            Contact:
            <asp:TextBox ID="ContactTextBox" runat="server" Text='<%# Bind("Contact") %>'>
            </asp:TextBox><br />
            Memo:
            <asp:TextBox ID="MemoTextBox" runat="server" Text='<%# Bind("Memo") %>'>
            </asp:TextBox><br />
            <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"
                Text="Update">
            </asp:LinkButton>
            <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="Cancel">
            </asp:LinkButton>
        </EditItemTemplate>
        <InsertItemTemplate>
            membernum:
            <asp:TextBox ID="membernumTextBox" runat="server" Text='<%# Bind("membernum") %>'>
            </asp:TextBox><br />
            prefix:&nbsp;
            <asp:DropDownList ID="DropDownList2" runat="server" SelectedValue='<%# Bind("prefix") %>'>
                <asp:ListItem Value="' '"></asp:ListItem>
                <asp:ListItem Selected="True">Dr</asp:ListItem>
                <asp:ListItem>Dcn</asp:ListItem>
                <asp:ListItem>Mr</asp:ListItem>
                <asp:ListItem>Mrs</asp:ListItem>
                <asp:ListItem>Msgr</asp:ListItem>
                <asp:ListItem>Rev</asp:ListItem>
                <asp:ListItem>SK</asp:ListItem>
            </asp:DropDownList><br />
            firstname:
            <asp:TextBox ID="firstnameTextBox" runat="server" Text='<%# Bind("firstname") %>'>
            </asp:TextBox><br />
            mi:
            <asp:TextBox ID="miTextBox" runat="server" Text='<%# Bind("mi") %>'>
            </asp:TextBox><br />
            lastname:
            <asp:TextBox ID="lastnameTextBox" runat="server" Text='<%# Bind("lastname") %>'>
            </asp:TextBox><br />
            suffix:&nbsp;
            <asp:DropDownList ID="DropDownList3" runat="server">
                <asp:ListItem></asp:ListItem>
                <asp:ListItem>DDS</asp:ListItem>
                <asp:ListItem>Jr</asp:ListItem>
                <asp:ListItem>Sr</asp:ListItem>
                <asp:ListItem>PGK</asp:ListItem>
                <asp:ListItem>PGK,FDD</asp:ListItem>
            </asp:DropDownList><br />
            name:
            <asp:TextBox ID="nameTextBox" runat="server" Text='<%# Bind("name") %>'>
            </asp:TextBox><br />
            address1:
            <asp:TextBox ID="address1TextBox" runat="server" Text='<%# Bind("address1") %>'>
            </asp:TextBox><br />
            address2:
            <asp:TextBox ID="address2TextBox" runat="server" Text='<%# Bind("address2") %>'>
            </asp:TextBox><br />
            city:
            <asp:TextBox ID="cityTextBox" runat="server" Text='<%# Bind("city") %>'>
            </asp:TextBox><br />
            state:
            <asp:TextBox ID="stateTextBox" runat="server" Text='<%# Bind("state") %>'>
            </asp:TextBox><br />
            postalcd:
            <asp:TextBox ID="postalcdTextBox" runat="server" Text='<%# Bind("postalcd") %>'>
            </asp:TextBox><br />
            homephone:
            <asp:TextBox ID="homephoneTextBox" runat="server" Text='<%# Bind("homephone") %>'>
            </asp:TextBox><br />
            homeac:
            <asp:TextBox ID="homeacTextBox" runat="server" Text='<%# Bind("homeac") %>'>
            </asp:TextBox><br />
            altphone:
            <asp:TextBox ID="altphoneTextBox" runat="server" Text='<%# Bind("altphone") %>'>
            </asp:TextBox><br />
            altac:
            <asp:TextBox ID="altacTextBox" runat="server" Text='<%# Bind("altac") %>'>
            </asp:TextBox><br />
            alttype:
            <asp:TextBox ID="alttypeTextBox" runat="server" Text='<%# Bind("alttype") %>'>
            </asp:TextBox><br />
            ssn:
            <asp:TextBox ID="ssnTextBox" runat="server" Text='<%# Bind("ssn") %>'>
            </asp:TextBox><br />
            birthday:
            <asp:TextBox ID="birthdayTextBox" runat="server" Text='<%# Bind("birthday", "{0:d}") %>' OnTextChanged="birthdayTextBox_TextChanged"></asp:TextBox><br />
            bmonth:
            <asp:TextBox ID="bmonthTextBox" runat="server" Text='<%# Bind("bmonth") %>'>
            </asp:TextBox><br />
            deceaseddt:
            <asp:TextBox ID="deceaseddtTextBox" runat="server" Text='<%# Bind("deceaseddt", "{0:d}") %>'></asp:TextBox><br />
            age:
            <asp:TextBox ID="ageTextBox" runat="server" Text='<%# Bind("age") %>'>
            </asp:TextBox><br />
            type:&nbsp;
            <asp:DropDownList ID="DropDownList1" runat="server" SelectedValue='<%# Bind("type") %>'>
                <asp:ListItem Selected="True">ASSOCIATE</asp:ListItem>
                <asp:ListItem>INSURANCE   </asp:ListItem>
                <asp:ListItem>INACTIVE  </asp:ListItem>
                <asp:ListItem>APPLICANT</asp:ListItem>
                <asp:ListItem>CANDIDATE</asp:ListItem>
                <asp:ListItem>MAIL LIST                     </asp:ListItem>
                <asp:ListItem>SUSPENDED-NON PAYMENT</asp:ListItem>
                <asp:ListItem>SUSPENDED-BOARD ACTION </asp:ListItem>
                <asp:ListItem>WITHDRAWAL</asp:ListItem>
                <asp:ListItem>TRANSFER OUT</asp:ListItem>
                <asp:ListItem>DECEASED </asp:ListItem>
                <asp:ListItem>PENDING-SUSPENSION    </asp:ListItem>
            </asp:DropDownList><br />
            class:&nbsp;
            <asp:DropDownList ID="DropDownList4" runat="server" SelectedValue='<%# Bind("class") %>'>
                <asp:ListItem Selected="True">NONE</asp:ListItem>
                <asp:ListItem>REGULAR</asp:ListItem>
                <asp:ListItem>INSURANCE</asp:ListItem>
                <asp:ListItem>HONORARY </asp:ListItem>
                <asp:ListItem>HONORARY LIFE </asp:ListItem>
                <asp:ListItem>DISABLED            </asp:ListItem>
                <asp:ListItem>DISABLED HONORARY </asp:ListItem>
                <asp:ListItem>Under26</asp:ListItem>
            </asp:DropDownList><br />
            annualdues:
            <asp:TextBox ID="annualduesTextBox" runat="server" Text='<%# Bind("annualdues", "{0:C}") %>'></asp:TextBox><br />
            marital:&nbsp;
            <asp:DropDownList ID="DropDownList6" runat="server" SelectedValue='<%# Bind("marital") %>'>
                <asp:ListItem Value="' '"></asp:ListItem>
                <asp:ListItem Selected="True">Clergy</asp:ListItem>
                <asp:ListItem>Single</asp:ListItem>
                <asp:ListItem>Married</asp:ListItem>
            </asp:DropDownList><br />
            parish:
            <asp:TextBox ID="parishTextBox" runat="server" Text='<%# Bind("parish") %>'>
            </asp:TextBox><br />
            fourth:
            <asp:CheckBox ID="fourthCheckBox" runat="server" Checked='<%# Bind("fourth") %>' /><br />
            assemblynm:
            <asp:TextBox ID="assemblynmTextBox" runat="server" Text='<%# Bind("assemblynm") %>'>
            </asp:TextBox><br />
            firstdeg:
            <asp:TextBox ID="firstdegTextBox" runat="server" Text='<%# Bind("firstdeg", "{0:d}") %>'></asp:TextBox><br />
            seconddeg:
            <asp:TextBox ID="seconddegTextBox" runat="server" Text='<%# Bind("seconddeg", "{0:d}") %>'></asp:TextBox><br />
            thirddeg:
            <asp:TextBox ID="thirddegTextBox" runat="server" Text='<%# Bind("thirddeg", "{0:d}") %>'></asp:TextBox><br />
            fourthdeg:
            <asp:TextBox ID="fourthdegTextBox" runat="server" Text='<%# Bind("fourthdeg", "{0:d}") %>'></asp:TextBox><br />
            degree:&nbsp;
            <asp:DropDownList ID="DropDownList5" runat="server" SelectedValue='<%# Bind("degree") %>'>
                <asp:ListItem Selected="True">NONE</asp:ListItem>
                <asp:ListItem>1ST</asp:ListItem>
                <asp:ListItem>2ND</asp:ListItem>
                <asp:ListItem>3RD</asp:ListItem>
                <asp:ListItem>4TH</asp:ListItem>
            </asp:DropDownList><br />
            senddegnot:
            <asp:TextBox ID="senddegnotTextBox" runat="server" Text='<%# Bind("senddegnot") %>'>
            </asp:TextBox><br />
            office:
            <asp:TextBox ID="officeTextBox" runat="server" Text='<%# Bind("office") %>'>
            </asp:TextBox><br />
            offnum:
            <asp:TextBox ID="offnumTextBox" runat="server" Text='<%# Bind("offnum") %>'>
            </asp:TextBox><br />
            fratyear:
            <asp:TextBox ID="fratyearTextBox" runat="server" Text='<%# Bind("fratyear") %>'>
            </asp:TextBox><br />
            billmessg1:
            <asp:TextBox ID="billmessg1TextBox" runat="server" Text='<%# Bind("billmessg1") %>'>
            </asp:TextBox><br />
            billmessg2:
            <asp:TextBox ID="billmessg2TextBox" runat="server" Text='<%# Bind("billmessg2") %>'>
            </asp:TextBox><br />
            billstatus:
            <asp:TextBox ID="billstatusTextBox" runat="server" Text='<%# Bind("billstatus") %>'>
            </asp:TextBox><br />
            bstatdate:
            <asp:TextBox ID="bstatdateTextBox" runat="server" Text='<%# Bind("bstatdate") %>'>
            </asp:TextBox><br />
            retcommdt:
            <asp:TextBox ID="retcommdtTextBox" runat="server" Text='<%# Bind("retcommdt") %>'>
            </asp:TextBox><br />
            former_sqr:
            <asp:CheckBox ID="former_sqrCheckBox" runat="server" Checked='<%# Bind("former_sqr") %>' /><br />
            Email:
            <asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>'>
            </asp:TextBox><br />
            paystat:
            <asp:TextBox ID="paystatTextBox" runat="server" Text='<%# Bind("paystat") %>'>
            </asp:TextBox><br />
            nobill:
            <asp:CheckBox ID="nobillCheckBox" runat="server" Checked='<%# Bind("nobill") %>' /><br />
            dead:
            <asp:CheckBox ID="deadCheckBox" runat="server" Checked='<%# Bind("dead") %>' /><br />
            duespaid:
            <asp:CheckBox ID="duespaidCheckBox" runat="server" Checked='<%# Bind("duespaid") %>' /><br />
            paidthru:
            <asp:TextBox ID="paidthruTextBox" runat="server" Text='<%# Bind("paidthru", "{0:d}") %>'></asp:TextBox><br />
            balancedue:
            <asp:TextBox ID="balancedueTextBox" runat="server" Text='<%# Bind("balancedue", "{0:C}") %>'></asp:TextBox><br />
            Contact:
            <asp:TextBox ID="ContactTextBox" runat="server" Text='<%# Bind("Contact") %>'>
            </asp:TextBox><br />
            Memo:
            <asp:TextBox ID="MemoTextBox" runat="server" Text='<%# Bind("Memo") %>'>
            </asp:TextBox><br />
            <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"
                Text="Insert">
            </asp:LinkButton>
            <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"
                Text="Cancel">
            </asp:LinkButton>
        </InsertItemTemplate>
        <ItemTemplate>
            pkid:
            <asp:Label ID="pkidLabel" runat="server" Text='<%# Eval("pkid") %>'></asp:Label><br />
            membernum:
            <asp:Label ID="membernumLabel" runat="server" Text='<%# Bind("membernum") %>'></asp:Label><br />
            prefix:
            <asp:Label ID="prefixLabel" runat="server" Text='<%# Bind("prefix") %>'></asp:Label><br />
            firstname:
            <asp:Label ID="firstnameLabel" runat="server" Text='<%# Bind("firstname") %>'></asp:Label><br />
            mi:
            <asp:Label ID="miLabel" runat="server" Text='<%# Bind("mi") %>'></asp:Label><br />
            lastname:
            <asp:Label ID="lastnameLabel" runat="server" Text='<%# Bind("lastname") %>'></asp:Label><br />
            suffix:
            <asp:Label ID="suffixLabel" runat="server" Text='<%# Bind("suffix") %>'></asp:Label><br />
            name:
            <asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name") %>'></asp:Label><br />
            address1:
            <asp:Label ID="address1Label" runat="server" Text='<%# Bind("address1") %>'></asp:Label><br />
            address2:
            <asp:Label ID="address2Label" runat="server" Text='<%# Bind("address2") %>'></asp:Label><br />
            city:
            <asp:Label ID="cityLabel" runat="server" Text='<%# Bind("city") %>'></asp:Label><br />
            state:
            <asp:Label ID="stateLabel" runat="server" Text='<%# Bind("state") %>'></asp:Label><br />
            postalcd:
            <asp:Label ID="postalcdLabel" runat="server" Text='<%# Bind("postalcd") %>'></asp:Label><br />
            homephone:
            <asp:Label ID="homephoneLabel" runat="server" Text='<%# Bind("homephone") %>'></asp:Label><br />
            homeac:
            <asp:Label ID="homeacLabel" runat="server" Text='<%# Bind("homeac") %>'></asp:Label><br />
            altphone:
            <asp:Label ID="altphoneLabel" runat="server" Text='<%# Bind("altphone") %>'></asp:Label><br />
            altac:
            <asp:Label ID="altacLabel" runat="server" Text='<%# Bind("altac") %>'></asp:Label><br />
            alttype:
            <asp:Label ID="alttypeLabel" runat="server" Text='<%# Bind("alttype") %>'></asp:Label><br />
            ssn:
            <asp:Label ID="ssnLabel" runat="server" Text='<%# Bind("ssn") %>'></asp:Label><br />
            birthday:
            <asp:Label ID="birthdayLabel" runat="server" Text='<%# Bind("birthday") %>'></asp:Label><br />
            bmonth:
            <asp:Label ID="bmonthLabel" runat="server" Text='<%# Bind("bmonth") %>'></asp:Label><br />
            deceaseddt:
            <asp:Label ID="deceaseddtLabel" runat="server" Text='<%# Bind("deceaseddt") %>'>
            </asp:Label><br />
            age:
            <asp:Label ID="ageLabel" runat="server" Text='<%# Bind("age") %>'></asp:Label><br />
            type:
            <asp:Label ID="typeLabel" runat="server" Text='<%# Bind("type") %>'></asp:Label><br />
            class:
            <asp:Label ID="classLabel" runat="server" Text='<%# Bind("class") %>'></asp:Label><br />
            annualdues:
            <asp:Label ID="annualduesLabel" runat="server" Text='<%# Bind("annualdues") %>'>
            </asp:Label><br />
            marital:
            <asp:Label ID="maritalLabel" runat="server" Text='<%# Bind("marital") %>'></asp:Label><br />
            parish:
            <asp:Label ID="parishLabel" runat="server" Text='<%# Bind("parish") %>'></asp:Label><br />
            fourth:
            <asp:CheckBox ID="fourthCheckBox" runat="server" Checked='<%# Bind("fourth") %>'
                Enabled="false" /><br />
            assemblynm:
            <asp:Label ID="assemblynmLabel" runat="server" Text='<%# Bind("assemblynm") %>'>
            </asp:Label><br />
            firstdeg:
            <asp:Label ID="firstdegLabel" runat="server" Text='<%# Bind("firstdeg") %>'></asp:Label><br />
            seconddeg:
            <asp:Label ID="seconddegLabel" runat="server" Text='<%# Bind("seconddeg") %>'></asp:Label><br />
            thirddeg:
            <asp:Label ID="thirddegLabel" runat="server" Text='<%# Bind("thirddeg") %>'></asp:Label><br />
            fourthdeg:
            <asp:Label ID="fourthdegLabel" runat="server" Text='<%# Bind("fourthdeg") %>'></asp:Label><br />
            degree:
            <asp:Label ID="degreeLabel" runat="server" Text='<%# Bind("degree") %>'></asp:Label><br />
            senddegnot:
            <asp:Label ID="senddegnotLabel" runat="server" Text='<%# Bind("senddegnot") %>'>
            </asp:Label><br />
            office:
            <asp:Label ID="officeLabel" runat="server" Text='<%# Bind("office") %>'></asp:Label><br />
            offnum:
            <asp:Label ID="offnumLabel" runat="server" Text='<%# Bind("offnum") %>'></asp:Label><br />
            fratyear:
            <asp:Label ID="fratyearLabel" runat="server" Text='<%# Bind("fratyear") %>'></asp:Label><br />
            billmessg1:
            <asp:Label ID="billmessg1Label" runat="server" Text='<%# Bind("billmessg1") %>'>
            </asp:Label><br />
            billmessg2:
            <asp:Label ID="billmessg2Label" runat="server" Text='<%# Bind("billmessg2") %>'>
            </asp:Label><br />
            billstatus:
            <asp:Label ID="billstatusLabel" runat="server" Text='<%# Bind("billstatus") %>'>
            </asp:Label><br />
            bstatdate:
            <asp:Label ID="bstatdateLabel" runat="server" Text='<%# Bind("bstatdate") %>'></asp:Label><br />
            retcommdt:
            <asp:Label ID="retcommdtLabel" runat="server" Text='<%# Bind("retcommdt") %>'></asp:Label><br />
            former_sqr:
            <asp:CheckBox ID="former_sqrCheckBox" runat="server" Checked='<%# Bind("former_sqr") %>'
                Enabled="false" /><br />
            Email:
            <asp:Label ID="EmailLabel" runat="server" Text='<%# Bind("Email") %>'></asp:Label><br />
            paystat:
            <asp:Label ID="paystatLabel" runat="server" Text='<%# Bind("paystat") %>'></asp:Label><br />
            nobill:
            <asp:CheckBox ID="nobillCheckBox" runat="server" Checked='<%# Bind("nobill") %>'
                Enabled="false" /><br />
            dead:
            <asp:CheckBox ID="deadCheckBox" runat="server" Checked='<%# Bind("dead") %>' Enabled="false" /><br />
            duespaid:
            <asp:CheckBox ID="duespaidCheckBox" runat="server" Checked='<%# Bind("duespaid") %>'
                Enabled="false" /><br />
            paidthru:
            <asp:Label ID="paidthruLabel" runat="server" Text='<%# Bind("paidthru") %>'></asp:Label><br />
            balancedue:
            <asp:Label ID="balancedueLabel" runat="server" Text='<%# Bind("balancedue") %>'>
            </asp:Label><br />
            Contact:
            <asp:Label ID="ContactLabel" runat="server" Text='<%# Bind("Contact") %>'></asp:Label><br />
            Memo:
            <asp:Label ID="MemoLabel" runat="server" Text='<%# Bind("Memo") %>'></asp:Label><br />
            <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"
                Text="Edit">
            </asp:LinkButton>
            <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"
                Text="Delete">
            </asp:LinkButton>
            <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"
                Text="New">
            </asp:LinkButton>
        </ItemTemplate>
    </asp:FormView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SQLFSPCConnectionString %>"
        DeleteCommand="DELETE FROM [Knights] WHERE [pkid] = @pkid" InsertCommand="INSERT INTO [Knights] ([membernum], [prefix], [firstname], [mi], [lastname], [suffix], [name], [address1], [address2], [city], [state], [postalcd], [homephone], [homeac], [altphone], [altac], [alttype], [ssn], [birthday], [bmonth], [deceaseddt], [age], [type], [class], [annualdues], [marital], [parish], [fourth], [assemblynm], [firstdeg], [seconddeg], [thirddeg], [fourthdeg], [degree], [senddegnot], [office], [offnum], [fratyear], [billmessg1], [billmessg2], [billstatus], [bstatdate], [retcommdt], [former_sqr], [Email], [paystat], [nobill], [dead], [duespaid], [paidthru], [balancedue], [Contact], [Memo]) VALUES (@membernum, @prefix, @firstname, @mi, @lastname, @suffix, @name, @address1, @address2, @city, @state, @postalcd, @homephone, @homeac, @altphone, @altac, @alttype, @ssn, @birthday, @bmonth, @deceaseddt, @age, @type, @class, @annualdues, @marital, @parish, @fourth, @assemblynm, @firstdeg, @seconddeg, @thirddeg, @fourthdeg, @degree, @senddegnot, @office, @offnum, @fratyear, @billmessg1, @billmessg2, @billstatus, @bstatdate, @retcommdt, @former_sqr, @Email, @paystat, @nobill, @dead, @duespaid, @paidthru, @balancedue, @Contact, @Memo)"
        SelectCommand="SELECT * FROM [Knights]" UpdateCommand="UPDATE [Knights] SET [membernum] = @membernum, [prefix] = @prefix, [firstname] = @firstname, [mi] = @mi, [lastname] = @lastname, [suffix] = @suffix, [name] = @name, [address1] = @address1, [address2] = @address2, [city] = @city, [state] = @state, [postalcd] = @postalcd, [homephone] = @homephone, [homeac] = @homeac, [altphone] = @altphone, [altac] = @altac, [alttype] = @alttype, [ssn] = @ssn, [birthday] = @birthday, [bmonth] = @bmonth, [deceaseddt] = @deceaseddt, [age] = @age, [type] = @type, [class] = @class, [annualdues] = @annualdues, [marital] = @marital, [parish] = @parish, [fourth] = @fourth, [assemblynm] = @assemblynm, [firstdeg] = @firstdeg, [seconddeg] = @seconddeg, [thirddeg] = @thirddeg, [fourthdeg] = @fourthdeg, [degree] = @degree, [senddegnot] = @senddegnot, [office] = @office, [offnum] = @offnum, [fratyear] = @fratyear, [billmessg1] = @billmessg1, [billmessg2] = @billmessg2, [billstatus] = @billstatus, [bstatdate] = @bstatdate, [retcommdt] = @retcommdt, [former_sqr] = @former_sqr, [Email] = @Email, [paystat] = @paystat, [nobill] = @nobill, [dead] = @dead, [duespaid] = @duespaid, [paidthru] = @paidthru, [balancedue] = @balancedue, [Contact] = @Contact, [Memo] = @Memo WHERE [pkid] = @pkid">
        <DeleteParameters>
            <asp:Parameter Name="pkid" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="membernum" Type="Decimal" />
            <asp:Parameter Name="prefix" Type="String" />
            <asp:Parameter Name="firstname" Type="String" />
            <asp:Parameter Name="mi" Type="String" />
            <asp:Parameter Name="lastname" Type="String" />
            <asp:Parameter Name="suffix" Type="String" />
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address1" Type="String" />
            <asp:Parameter Name="address2" Type="String" />
            <asp:Parameter Name="city" Type="String" />
            <asp:Parameter Name="state" Type="String" />
            <asp:Parameter Name="postalcd" Type="String" />
            <asp:Parameter Name="homephone" Type="String" />
            <asp:Parameter Name="homeac" Type="String" />
            <asp:Parameter Name="altphone" Type="String" />
            <asp:Parameter Name="altac" Type="String" />
            <asp:Parameter Name="alttype" Type="String" />
            <asp:Parameter Name="ssn" Type="String" />
            <asp:Parameter DbType="DateTime" Name="birthday" />
            <asp:Parameter Name="bmonth" Type="String" />
            <asp:Parameter DbType="DateTime" Name="deceaseddt" />
            <asp:Parameter Name="age" Type="Decimal" />
            <asp:Parameter Name="type" Type="String" />
            <asp:Parameter Name="class" Type="String" />
            <asp:Parameter Name="annualdues" Type="Decimal" />
            <asp:Parameter Name="marital" Type="String" />
            <asp:Parameter Name="parish" Type="String" />
            <asp:Parameter Name="fourth" Type="Boolean" />
            <asp:Parameter Name="assemblynm" Type="Decimal" />
            <asp:Parameter DbType="DateTime" Name="firstdeg" />
            <asp:Parameter DbType="DateTime" Name="seconddeg" />
            <asp:Parameter DbType="DateTime" Name="thirddeg" />
            <asp:Parameter DbType="DateTime" Name="fourthdeg" />
            <asp:Parameter Name="degree" Type="String" />
            <asp:Parameter Name="senddegnot" Type="String" />
            <asp:Parameter Name="office" Type="String" />
            <asp:Parameter Name="offnum" Type="Decimal" />
            <asp:Parameter Name="fratyear" Type="Decimal" />
            <asp:Parameter Name="billmessg1" Type="String" />
            <asp:Parameter Name="billmessg2" Type="String" />
            <asp:Parameter Name="billstatus" Type="String" />
            <asp:Parameter DbType="DateTime" Name="bstatdate" />
            <asp:Parameter DbType="DateTime" Name="retcommdt" />
            <asp:Parameter Name="former_sqr" Type="Boolean" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="paystat" Type="String" />
            <asp:Parameter Name="nobill" Type="Boolean" />
            <asp:Parameter Name="dead" Type="Boolean" />
            <asp:Parameter Name="duespaid" Type="Boolean" />
            <asp:Parameter DbType="DateTime" Name="paidthru" />
            <asp:Parameter Name="balancedue" Type="Decimal" />
            <asp:Parameter Name="Contact" Type="String" />
            <asp:Parameter Name="Memo" Type="String" />
            <asp:Parameter Name="pkid" Type="Int32" />
        </UpdateParameters>
        <InsertParameters>
            <asp:Parameter Name="membernum" Type="Decimal" />
            <asp:Parameter Name="prefix" Type="String" />
            <asp:Parameter Name="firstname" Type="String" />
            <asp:Parameter Name="mi" Type="String" />
            <asp:Parameter Name="lastname" Type="String" />
            <asp:Parameter Name="suffix" Type="String" />
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address1" Type="String" />
            <asp:Parameter Name="address2" Type="String" />
            <asp:Parameter Name="city" Type="String" />
            <asp:Parameter Name="state" Type="String" />
            <asp:Parameter Name="postalcd" Type="String" />
            <asp:Parameter Name="homephone" Type="String" />
            <asp:Parameter Name="homeac" Type="String" />
            <asp:Parameter Name="altphone" Type="String" />
            <asp:Parameter Name="altac" Type="String" />
            <asp:Parameter Name="alttype" Type="String" />
            <asp:Parameter Name="ssn" Type="String" />
            <asp:Parameter DbType="DateTime" Name="birthday" />
            <asp:Parameter Name="bmonth" Type="String" />
            <asp:Parameter DbType="DateTime" Name="deceaseddt" />
            <asp:Parameter Name="age" Type="Decimal" />
            <asp:Parameter Name="type" Type="String" />
            <asp:Parameter Name="class" Type="String" />
            <asp:Parameter Name="annualdues" Type="Decimal" />
            <asp:Parameter Name="marital" Type="String" />
            <asp:Parameter Name="parish" Type="String" />
            <asp:Parameter Name="fourth" Type="Boolean" />
            <asp:Parameter Name="assemblynm" Type="Decimal" />
            <asp:Parameter DbType="DateTime" Name="firstdeg" />
            <asp:Parameter DbType="DateTime" Name="seconddeg" />
            <asp:Parameter DbType="DateTime" Name="thirddeg" />
            <asp:Parameter DbType="DateTime" Name="fourthdeg" />
            <asp:Parameter Name="degree" Type="String" />
            <asp:Parameter Name="senddegnot" Type="String" />
            <asp:Parameter Name="office" Type="String" />
            <asp:Parameter Name="offnum" Type="Decimal" />
            <asp:Parameter Name="fratyear" Type="Decimal" />
            <asp:Parameter Name="billmessg1" Type="String" />
            <asp:Parameter Name="billmessg2" Type="String" />
            <asp:Parameter Name="billstatus" Type="String" />
            <asp:Parameter DbType="DateTime" Name="bstatdate" />
            <asp:Parameter DbType="DateTime" Name="retcommdt" />
            <asp:Parameter Name="former_sqr" Type="Boolean" />
            <asp:Parameter Name="Email" Type="String" />
            <asp:Parameter Name="paystat" Type="String" />
            <asp:Parameter Name="nobill" Type="Boolean" />
            <asp:Parameter Name="dead" Type="Boolean" />
            <asp:Parameter Name="duespaid" Type="Boolean" />
            <asp:Parameter DbType="DateTime" Name="paidthru" />
            <asp:Parameter Name="balancedue" Type="Decimal" />
            <asp:Parameter Name="Contact" Type="String" />
            <asp:Parameter Name="Memo" Type="String" />
        </InsertParameters>
    </asp:SqlDataSource>
</asp:Content>

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
BTosonCommented:
Withough going through all your code, Ithink this should work:
Protected Sub birthdayTextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
	Dim BirthdayDate As DateTime
	If IsDate(birthdayTextBox.Text) AndAlso DateTime.TryParse(birthdayTextBox.Text, BirthdayDate) Then
		Age.Text = DateDiff(DateInterval.Year, BirthdayDate, Now)
	End If
End Sub

Open in new window

0
 
pgkdavefddAuthor Commented:
 BToson, I tried adding the following code as you suggested and I get an errors stating that
Name Textbox3 and Textbox1 have not been declared  

Protected Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim BirthdayDate As DateTime
        If IsDate(TextBox3.Text) AndAlso DateTime.TryParse(TextBox3.Text, BirthdayDate) Then
           TextBox1.Text = DateDiff(DateInterval.Year, BirthdayDate, Now)
        End If

textbox1 is the textbox used in the edit item temp plate for Age and Textbox3 is the one used for Birthday.  I said that I am new to this.  What am I doing wrong?
    End Sub
0
 
BTosonCommented:
Unfortunately I don't use FormViews at all but this should work:
Protected Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
	Dim Birthday = CType(FormView1.Row.FindControl("TextBox3"), TextBox).Text
	Dim BirthdayDate As DateTime
	If IsDate(Birthday) AndAlso DateTime.TryParse(Birthday, BirthdayDate) Then
		 CType(FormView1.Row.FindControl("TextBox1"), TextBox).Text = DateDiff(DateInterval.Year, BirthdayDate, Now)
	End If
End Sub

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now