Link to home
Start Free TrialLog in
Avatar of David Megnin
David MegninFlag for United States of America

asked on

Can't reference a label and image in ItemTemplate of FormView

I have a FormView I'm trying to put a "status indicator" in the ItemTemplate to indicate whether the value in the databound field is a 1, 2 or 3.  The label in the ItemTemplate displays the correct value, but I'm having troubel referencing the label, "Status", and the image, "Image1".  With the (now commented out) code in the Snippet window I get an "Object not set to an instance of an object" error.


      <asp:RadioButtonList ID="radStatus" runat="server" RepeatDirection="Vertical"
                               RepeatLayout="Flow"
                               DataSourceID="SqlDataSource1"
                               DataTextField="Status"
                               DataValueField="keyApplicantID"
                               SelectedValue='<%# Bind("Status") %>'
                               AppendDataBoundItems="True"
                               >
      <asp:ListItem Value="0">None</asp:ListItem>
      <asp:ListItem Value="1">Complete</asp:ListItem>
      <asp:ListItem Value="2">Pending</asp:ListItem>
      <asp:ListItem Value="3">Ineligable</asp:ListItem>
</asp:RadioButtonList>                        
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'If FormView1.CurrentMode = FormViewMode.ReadOnly Then
        '    Dim StatusLabel As Label = CType(FormView1.FindControl("Status"), Label)
        '    Dim StatusImage As Image = CType(FormView1.FindControl("Image1"), Image)
        '    If StatusLabel.Text = "1" Then
        '        StatusImage.ImageUrl = "~/images/StatusGreen.png"
        '    ElseIf StatusLabel.Text = "2" Then
        '        StatusImage.ImageUrl = "~/images/StatusYellow.png"
        '    ElseIf StatusLabel.Text = "3" Then
        '        StatusImage.ImageUrl = "~/images/StatusRed.png"
        '    Else
        '        StatusImage.ImageUrl = "~/images/blankImage.gif"
        '    End If
        'End If
 
End Sub

Open in new window

Avatar of aibusinesssolutions
aibusinesssolutions
Flag of United States of America image

Can you paste the code you have for your FormView?  All I see is code for the RadioButtonList
Why can't you just say:



Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'If FormView1.CurrentMode = FormViewMode.ReadOnly Then
        '    If Status.Text = "1" Then
        '        Image1.ImageUrl = "~/images/StatusGreen.png"
        '    ElseIf Status.Text = "2" Then
        '        Image1.ImageUrl = "~/images/StatusYellow.png"
        '    ElseIf Status.Text = "3" Then
        '        Image1.ImageUrl = "~/images/StatusRed.png"
        '    Else
        '        Image1.ImageUrl = "~/images/blankImage.gif"
        '    End If
        'End If
 End Sub

Open in new window

Avatar of David Megnin

ASKER

aibusinesssol...,
Um, okay, but the RadioButtonList is really the only relevant piece.  It's between a <td> and </td> in the ItemTemplate, like I mentioned.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Applicant_Verification.aspx.vb" Inherits="Applicant_Verification" %>
 
<!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">
    <title>Applicant Verification</title>
<!--link rel="stylesheet" type="text/css" href="css/StyleSheet.css" /-->
    
<style type="text/css">    
/*
.tab {
position:absolute;
left:9em;
width:17em;
}    
.container {position: relative; width: 100%; }
.copy {position: absolute; left: 300px; top: 0px; margin-top:2em; width: 435px; }
 
 
*/
h1	  {color:#8c004c; text-align:center; margin-left:auto; margin-right:auto; margin-bottom: 0px; padding-bottom: 0px; vertical-align:bottom; font-size:x-large;}
h2	  {text-align:center;}
 
.tab 
{
	Position:relative;
	}
 
.left {float:left;}
.right {float:right;}
.center { text-align: center; }
 
img { border-style:none; }
td { height:auto;}
input { height:15px;}
input.submit { height:auto;}
 
.moveDropDownLeft
{
	Position:relative;
	left:-13em;
	}
 
 
	.underlined
	{
		text-decoration: underline;
	}
 
 
</style>
 
</head>
<body>
    <form id="form1" runat="server">
 
        <div>
            <table border="0" style="margin-left:auto; margin-right:auto; width:100%;">
                <tr><td>
						<%--<a href="http://www.wf1broward.com" ><img src="images/WF1_Logo009.gif" alt="WorkForce One Logo" class="left" width="237" height="80"/></a>--%>
						<a href="http://www.wf1broward.com" ><img src="images/WF1_Logo009.gif" alt="WorkForce One Logo" class="left" width="118" height="40"/></a>
					</td>
                    <td>
						<div>
							<h1>SYEP 2009&nbsp; -&nbsp; Information Verification</h1>
                        </div>
                    </td>
                    <td>
						<%--<a href="http://www.cscbroward.org/"><img src="images/CSC_Logo10.gif" alt="Children's Services Council Logo" class="right" width="125" height="80" /></a>--%>
						<a href="http://www.cscbroward.org/"><img src="images/CSC_Logo10.gif" alt="Children's Services Council Logo" class="right" width="62" height="40" /></a>
                    </td>
                </tr>
            </table>
        </div>
    <hr />
 
		<asp:ScriptManager ID="ScriptManager1" runat="server">
		</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
	<ContentTemplate>
 
 
<div style="float:left; position:relative; left:2em;">
<span style="font-style:italic; color:Gray;">Press "F5" to refresh your login name.</span>
<br />
<br />
	<asp:Label ID="lblUserName" runat="server" Text="Not Logged In"></asp:Label>
	<br />
	<br />
	<asp:Button ID="btnLogOff" runat="server" Text="Log Off" Height="25px" />
</div>
<div style="text-align:center; font-style:italic; color:Fuchsia;">
	Log Off when you leave the computer for <span class="underlined">any</span> reason!
</div>
<div style="margin:3px auto 5px auto; width:20%;">
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" 
            DataSourceID="SqlDataSource2" DataTextField="NameAndSSN" CssClass="moveDropDownLeft"
            DataValueField="keyApplicantID">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
            ConnectionString="<%$ ConnectionStrings:SYEP2007ConnectionString1 %>" 
			SelectCommand="SELECT keyApplicantID, LastName + ', ' + FirstName + ', XXX-XX-' + RIGHT (SSN, 4) AS NameAndSSN FROM Applicants WHERE (keyApplicantID &gt; 200900000) AND (txtConsidered = 'Y') ORDER BY LastName, FirstName">
        </asp:SqlDataSource>
</div>     
       
<%--<div class="container"> <!-- Container class allows copy class to position the FormView and lets the fields use absolute positioning-->--%>
 
<div style="margin-left:auto; margin-right:auto; text-align:center;">
 
        <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" 
            BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" 
            CellPadding="3" GridLines="Horizontal" 
            DataKeyNames="keyApplicantID">
            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
            <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
            <EditItemTemplate>
            <table style="text-align:left; width:400px;">
            <tr>
            <td>
                ApplicantID:
            </td>
            <td>
                <asp:Label ID="keyApplicantIDLabel1" runat="server" Text='<%# Bind("keyApplicantID") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Last Name:
            </td>
            <td>
                <asp:TextBox ID="LastNameTextBox" runat="server" Text='<%# Bind("LastName") %>' CssClass="tab"/>
			</td>
			</tr>
			<tr>
			<td>
                First Name:
            </td>
            <td>
                <asp:TextBox ID="FirstNameTextBox" runat="server" Text='<%# Bind("FirstName") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                MI:
            </td>
            <td>
                <asp:TextBox ID="MITextBox" runat="server" Text='<%# Bind("MI") %>' CssClass="tab" MaxLength="1" Width="15px" />
			</td>
			</tr>
			<tr>
			<td>
                DOB:
            </td>
            <td>    
                <asp:TextBox ID="DOBTextBox" runat="server" Text='<%# Bind("DOB", "{0:d}") %>' CssClass="" CausesValidation="True" />
                <asp:RangeValidator ID="RangeValidator1" runat="server" 
                    ControlToValidate="DOBTextBox" ErrorMessage="Not Eligible" Font-Size="X-Small" 
                    MaximumValue="6/8/1993" MinimumValue="6/9/1990" Type="Date" 
                    Enabled="False">
                </asp:RangeValidator>
			</td>
			</tr>
			<tr>
			<td>
                SSN:
            </td>
            <td>
                <asp:TextBox ID="SSNTextBox" runat="server" Text='<%# Bind("SSN") %>' CssClass="tab" MaxLength="9" />
			</td>
			</tr>
			<tr>
			<td>
                Address:
            </td>
            <td>
                <asp:TextBox ID="StreetNameTextBox" runat="server" Text='<%# Bind("StreetName") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
<%--
                CityID:
                <asp:TextBox ID="CityIDTextBox" runat="server" Text='<%# Bind("CityID") %>' CssClass="tab" ReadOnly="True" />
                <br />
                ZipID:
                <asp:TextBox ID="ZipIDTextBox" runat="server" Text='<%# Bind("ZipID") %>' CssClass="tab" ReadOnly="True" />
                <br />
--%>                
                City:
            </td>
            <td>
                <asp:TextBox ID="CityNameTextBox" runat="server" Text='<%# Bind("CityName") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Zip:
<%--                <asp:DropDownList ID="DropDownList1" runat="server"
	                DataSourceID="SqlDataSource3"
	                DataTextField="City"
	                DataValueField="Zip"
	                SelectedValue='<%# Bind("Zip") %>' AutoPostBack="True" />
--%>
			</td>
			<td>
                <asp:TextBox ID="ZipCodeTextBox" runat="server" Text='<%# Bind("ZipCode") %>' CssClass="tab" MaxLength="5" Width="50px" />
<%--                <asp:Dropdownlist ID="ZipCodeTextBox" runat="server" 
                    Text='<%# Bind("ZipCode") %>' CssClass="tab" AutoPostBack="True" 
                    SelectedValue='<%# Bind("ZipCode") %>' />
--%>            
			</td>
			</tr>
			<tr>
			<td>
                Telephone:
            </td>
            <td>
                <asp:TextBox ID="txtHomeTelephoneTextBox" runat="server" Text='<%# Bind("txtHomeTelephone") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Cellphone:
            </td>
            <td>
                <asp:TextBox ID="txtCellphoneTextBox" runat="server" Text='<%# Bind("txtCellphone") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Household Income:
            </td>
            <td>
                <asp:TextBox ID="HouseHoldIncomeID" runat="server" Text='<%# Bind("HouseHoldIncomeID") %>' CssClass="tab" MaxLength="1" Width="15px" />
			</td>
			</tr>
			<tr>
			<td>
                Considered:
            </td>
            <td>
                <asp:TextBox ID="txtConsideredTextBox" runat="server" Text='<%# Bind("txtConsidered") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Verified:
			</td>
			<td>                
                <asp:CheckBox ID="CheckBox1" runat="server" Checked='<%# Bind("Verify") %>' />
			</td>
			</tr>
			<tr>
			<td>
                Orientation Location:
            </td>
            <td>
                <asp:TextBox ID="OrientationLocation" runat="server" Text='<%# Bind("OrientationLocation") %>' MaxLength="1" Width="2em" />
			</td>
			</tr>
			<tr>
			<td>
                Status:
            </td>
            <td>
				<asp:RadioButtonList ID="radStatus" runat="server" RepeatDirection="Vertical" 
								 RepeatLayout="Flow" 
								 DataSourceID="SqlDataSource1"
								 DataTextField="Status"
								 DataValueField="keyApplicantID"
								 SelectedValue='<%# Bind("Status") %>'
								 AppendDataBoundItems="True" 
								 >
  				<asp:ListItem Value="0">None</asp:ListItem>
  				<asp:ListItem Value="1">Complete</asp:ListItem>
  				<asp:ListItem Value="2">Pending</asp:ListItem>
  				<asp:ListItem Value="3">Ineligable</asp:ListItem>
  			</asp:RadioButtonList>
			</td>
			</tr>
			
			</table>
                <br />
                <div>
                <asp:Button ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Save" 
						CssClass="submit" onclick="UpdateButton_Click" />&nbsp;
                <asp:Button ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" CssClass="submit" />
                </div>
            </EditItemTemplate>
            <InsertItemTemplate>
                LastName:
                <asp:TextBox ID="LastNameTextBox" runat="server" Text='<%# Bind("LastName") %>' />
                <br />
                FirstName:
                <asp:TextBox ID="FirstNameTextBox" runat="server" Text='<%# Bind("FirstName") %>' />
                <br />
                MI:
                <asp:TextBox ID="MITextBox" runat="server" Text='<%# Bind("MI") %>' />
                <br />
                DOB:
                <asp:TextBox ID="DOBTextBox" runat="server" Text='<%# Bind("DOB") %>' />
                <br />
                SSN:
                <asp:TextBox ID="SSNTextBox" runat="server" Text='<%# Bind("SSN") %>' />
                <br />
                StreetName:
                <asp:TextBox ID="StreetNameTextBox" runat="server" Text='<%# Bind("StreetName") %>' />
                <br />
                CityID:
                <asp:TextBox ID="CityIDTextBox" runat="server" Text='<%# Bind("CityID") %>' />
                <br />
                ZipID:
                <asp:TextBox ID="ZipIDTextBox" runat="server" Text='<%# Bind("ZipID") %>' />
                <br />
                CityName:
                <asp:TextBox ID="CityNameTextBox" runat="server" Text='<%# Bind("CityName") %>' />
                <br />
                ZipCode:
                <asp:TextBox ID="ZipCodeTextBox" runat="server" Width="4em" Text='<%# Bind("ZipCode") %>'/>
                <br />
                txtHomeTelephone:
                <asp:TextBox ID="txtHomeTelephoneTextBox" runat="server" Text='<%# Bind("txtHomeTelephone") %>' />
                <br />
                txtCellphone:
                <asp:TextBox ID="txtCellphoneTextBox" runat="server" Text='<%# Bind("txtCellphone") %>' />
                <br />
                Considered:
                <asp:TextBox ID="txtConsideredTextBox" runat="server" Width="2em" Text='<%# Bind("txtConsidered") %>' />
                <br />
                Verify:
                <asp:TextBox ID="VerifyTextBox" runat="server" Width="3em" Text='<%# Bind("Verify") %>' />
                <br />
                <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" /> &nbsp;
                <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />
            </InsertItemTemplate>
            <ItemTemplate>
            <table style="text-align:left; width:400px;">
            <tr>
            <td>
                ApplicantID:
			</td>
			<td>
                <asp:Label ID="keyApplicantIDLabel1" runat="server" Text='<%# Bind("keyApplicantID") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Last Name:
			</td>
			<td>
                <asp:Label ID="LastNameLabel" runat="server" Text='<%# Bind("LastName") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                First Name:
			</td>
			<td>
                <asp:Label ID="FirstNameLabel" runat="server" Text='<%# Bind("FirstName") %>' CssClass="tab"/>
			</td>
			</tr>
			<tr>
			<td>
                MI:
			</td>
			<td>
                <asp:Label ID="MILabel" runat="server" Text='<%# Bind("MI") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                DOB:
			</td>
			<td>
                <asp:Label ID="DOBLabel" runat="server" Text='<%# Bind("DOB", "{0:d}") %>' 
                    CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                SSN:
			</td>
			<td>
                <asp:Label ID="SSNLabel" runat="server" Text='<%# Bind("SSN") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Address:
			</td>
			<td>
                <asp:Label ID="StreetNameLabel" runat="server" Text='<%# Bind("StreetName") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
 
<%--                CityID:
                <asp:Label ID="CityIDLabel" runat="server" Text='<%# Bind("CityID") %>' CssClass="tab" />
                <br />
                ZipID:
                <asp:Label ID="ZipIDLabel" runat="server" Text='<%# Bind("ZipID") %>' CssClass="tab" />
                <br />
--%>
                City:
			</td>
			<td>
                <asp:Label ID="CityNameLabel" runat="server" Text='<%# Bind("CityName") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Zip:
			</td>
			<td>
                <asp:Label ID="ZipCodeLabel" runat="server" Text='<%# Bind("ZipCode") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Telephone:
			</td>
			<td>
                <asp:Label ID="txtHomeTelephoneLabel" runat="server" Text='<%# Bind("txtHomeTelephone") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Cellphone:
			</td>
			<td>
                <asp:Label ID="txtCellphoneLabel" runat="server" Text='<%# Bind("txtCellphone") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Household Income:
			</td>
			<td>
                <asp:Label ID="HouseHoldIncomeID" runat="server" Text='<%# Bind("HouseHoldIncomeID") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Considered:
			</td>
			<td>
                <asp:Label ID="txtConsideredLabel" runat="server" Text='<%# Bind("txtConsidered") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Verified:
			</td>
			<td>
                <asp:Label ID="VerifyLabel" runat="server" Text='<%# Bind("Verify") %>' CssClass="tab" />
			</td>
			</tr>
			<tr>
			<td>
                Location:
			</td>
			<td>
                <asp:Label ID="OrientationLocation" runat="server" Text='<%# Bind("OrientationLocation") %>' CssClass="tab" />
			</td>
			</tr>
				<tr>
					<td>
						Status:
					</td>
					<td>
						<asp:Label ID="Status" runat="server" Text='<%# Bind("Status") %>' CssClass="tab" />
						<%--<asp:Image ID="Image1" runat="server" ImageUrl="~/images/arrow007.gif" />--%>
					</td>
				</tr>
			</table>                
<br />
                <div>
                <asp:Button ID="editbutton" runat="server" CausesValidation="True" CommandName="Edit" Text="Edit" CssClass="submit" />
                <%--<asp:Button ID="InsertButton" runat="server" CausesValidation="true" CommandName="New" Text="New" />--%>
                </div>
            </ItemTemplate>
            <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
            <FooterTemplate>
                <div>
                WorkForce One
                </div>
            </FooterTemplate>
            <HeaderStyle BackColor="#006D75" Font-Bold="True" ForeColor="#F7F7F7" />
            <HeaderTemplate>
                <div>
                    SYEP 2009 Identification Verification
                </div>
            </HeaderTemplate>
            <EditRowStyle BackColor="#8C004C" Font-Bold="True" ForeColor="#F7F7F7" />
        </asp:FormView>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:SYEP2007ConnectionString1 %>" 
            DeleteCommand="DELETE FROM Applicants WHERE (keyApplicantID = @original_keyApplicantID) " 
            InsertCommand="INSERT INTO Applicants(LastName, FirstName, MI, SSN, StreetName, CityID, ZipID, DOB, txtHomeTelephone, txtCellphone, CityName, ZipCode, Verify, txtConsidered, ddlActivityType, HouseholdIncomeID, Verified, Pending, Ineligible, Status) VALUES (@LastName, @FirstName, @MI, @SSN, @StreetName, @CityID, @ZipID, @DOB, @txtHomeTelephone, @txtCellphone, @CityName, @ZipCode, @Verify, @txtConsidered, @OrientationLocation, @HouseholdIncomeID, @Verified, @Pending, @Ineligible, @Status)" 
            SelectCommand="SELECT keyApplicantID, LastName, FirstName, MI, SSN, StreetName, CityID, ZipID, DOB, txtHomeTelephone, txtCellphone, CityName, ZipCode, Verify, txtConsidered, OrientationLocation, HouseholdIncomeID, Verified, Pending, Ineligible, Status FROM Applicants WHERE (keyApplicantID = @keyApplicantID)" 
			
			
			UpdateCommand="UPDATE Applicants SET LastName = @LastName, FirstName = @FirstName, MI = @MI, SSN = @SSN, StreetName = @StreetName, CityID = @CityID, ZipID = @ZipID, DOB = @DOB, txtHomeTelephone = @txtHomeTelephone, txtCellphone = @txtCellphone, CityName = @CityName, ZipCode = @ZipCode, Verify = @Verify, txtConsidered = @txtConsidered, OrientationLocation = @OrientationLocation, HouseholdIncomeID = @HouseholdIncomeID, Verified = @Verified, Pending = @Pending, Ineligible = @Ineligible, Status = @Status WHERE (keyApplicantID = @keyApplicantID)">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="keyApplicantID" PropertyName="SelectedValue" Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_keyApplicantID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="LastName" Type="String" />
                <asp:Parameter Name="FirstName" Type="String" />
                <asp:Parameter Name="MI" Type="String" />
                <asp:Parameter Name="SSN" Type="String" />
                <asp:Parameter Name="StreetName" Type="String" />
                <asp:Parameter Name="CityID" Type="Int32" />
                <asp:Parameter Name="ZipID" Type="Int32" />
                <asp:Parameter Name="DOB" Type="DateTime" />
                <asp:Parameter Name="txtHomeTelephone" Type="String" />
                <asp:Parameter Name="txtCellphone" Type="String" />
                <asp:Parameter Name="CityName" Type="String" />
                <asp:Parameter Name="ZipCode" Type="Int32" />
                <asp:Parameter Name="Verify" Type="String" />
                <asp:Parameter Name="txtConsidered" />
                <asp:Parameter Name="OrientationLocation" />
                <asp:Parameter Name="HouseholdIncomeID" />
                <asp:Parameter Name="Verified" />
				<asp:Parameter Name="Pending" />
				<asp:Parameter Name="Ineligible" />
                <asp:Parameter Name="Status" />
                <asp:Parameter Name="keyApplicantID" />
            </UpdateParameters>
            <InsertParameters>
                <asp:Parameter Name="LastName" Type="String" />
                <asp:Parameter Name="FirstName" Type="String" />
                <asp:Parameter Name="MI" Type="String" />
                <asp:Parameter Name="SSN" Type="String" />
                <asp:Parameter Name="StreetName" Type="String" />
                <asp:Parameter Name="CityID" Type="Int32" />
                <asp:Parameter Name="ZipID" Type="Int32" />
                <asp:Parameter Name="DOB" Type="DateTime" />
                <asp:Parameter Name="txtHomeTelephone" Type="String" />
                <asp:Parameter Name="txtCellphone" Type="String" />
                <asp:Parameter Name="CityName" Type="String" />
                <asp:Parameter Name="ZipCode" Type="Int32" />
                <asp:Parameter Name="Verify" Type="String" />
                <asp:Parameter Name="txtConsidered" />
                <asp:Parameter Name="OrientationLocation" />
            	<asp:Parameter Name="HouseholdIncomeID" />
            	<asp:Parameter Name="Verified" />
				<asp:Parameter Name="Pending" />
				<asp:Parameter Name="Ineligible" />
            	<asp:Parameter Name="Status" />
            </InsertParameters>
        </asp:SqlDataSource>
</div>        
 
	</ContentTemplate>
</asp:UpdatePanel>
<div style="text-align:center;">
Date of Birth must be on or AFTER 06/09/90 AND BEFORE or on 06/8/93.
</div>
 
        <br />
        <div style="margin: 1em 5em 1em 5em; font-family:Constantia; font-size:large; text-align:center;" >
        Select a record from the Drop-Down to verify.p-Down to verify.<br />
        If "Editing Record: " does not show a the record number or the record display is disabled, re-select a record.
        </div>
		<%--
                CityID:
                <asp:TextBox ID="CityIDTextBox" runat="server" Text='<%# Bind("CityID") %>' CssClass="tab" ReadOnly="True" />
                <br />
                ZipID:
                <asp:TextBox ID="ZipIDTextBox" runat="server" Text='<%# Bind("ZipID") %>' CssClass="tab" ReadOnly="True" />
                <br />
--%>        
    
    </form>
</body>
</html>

Open in new window

nmarun, because the label "Status" and the "Image1" are in the FormView ItemTemplate and so causes and error which tells me, "Name 'Status' is not declared" and "Name 'Image1' is not declared".

I've seen other posts which indicate that I have to use something like:
Dim StatusLabel As Label = CType(FormView1.FindControl("Status"), Label)
to gain access to those controls.

Have none of the "Experts" here ever referenced a control inside a FormView?

I'm just learning and finding myself in need of referencing labels and textboxes and such inside a FormView.  I can't believe that this isn't something that's "common knowledge" among veteran programmers.  

I searched for the answer before asking the question and it seems like this is either something so bizzar, you just don't do it, or the experts aren't willing to share this "secret".  I'm sorry if I sound frustrated.  I am.
I don't see how the RadioButtonList is relevant to your question at all.  You want to figure out how to access Image1 and the Status Label.

In your code the Image1 tag is commented out with <%-- --%>, so you won't be able to access it at all.
ASKER CERTIFIED SOLUTION
Avatar of aibusinesssolutions
aibusinesssolutions
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I commented it out in my code because it doesn't work and my app in live and in use.  I should have uncommented it before posting it, but I didn't.  Sorry.

You're right, the RadioButtonList isn't very relevant, it's only setting the value of the label.  The RadioButtonList is in the EditItemTemplate and the label, which I'm concerned with, is in the ItemTemplate.  I thought the RadioButtonList code may show how I'm trying to use the label.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It looks promising, but I got this:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 40:             Dim lbl As Label = (FormView1.FindControl("Label1")
Line 41:             Dim img As Image = (FormView1.FindControl("Image1")
Line 42: *            Response.Write(lbl.Text)
Line 43:             Response.Write(img.ImageUrl)
Line 44:         End If
 

Source File: E:\Inetpub\SYEP\Applicant_Verification.aspx.vb    Line: 42

the FormView1_DataBound function?  Where would I find that?  It's not in my codebehind.
You see the two drop downs at the top of the code behind editor?

Click the drop down on the left and select FormView1, then click the one on the right and select DataBound, it will create the function for you and wire it up.
Okay, I added one:

   Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
        If FormView1.CurrentMode = FormViewMode.ReadOnly Then
            Dim lbl As Label = FormView1.FindControl("Label1")
            Dim img As Image = FormView1.FindControl("Image1")
            Response.Write(lbl.Text)
            Response.Write(img.ImageUrl)
        End If
    End Sub

I still get the same error, just on the new line:

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 131:            Dim lbl As Label = FormView1.FindControl("Label1")
Line 132:            Dim img As Image = FormView1.FindControl("Image1")
Line 133:            Response.Write(lbl.Text)
Line 134:            Response.Write(img.ImageUrl)
Line 135:        End If
 

Source File: E:\Inetpub\SYEP\Applicant_Verification.aspx.vb    Line: 133
Do you have a Label1 in your <ItemTemplate>?  I just used that as an example
With this in my FormView:

                                    Status:
                              </td>
                              <td>
                                    <%--<asp:Label ID="Status" runat="server" Text='<%# Bind("Status") %>' CssClass="tab" />--%>
                                    <%--<asp:Image ID="Image1" runat="server" ImageUrl="~/images/arrow007.gif" />--%>
                                    <asp:Label ID="Status" runat="server" Text='<%# Eval("keyApplicantID") %>'></asp:Label>
                                    <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("keyApplicantID") %>' />
                              </td>


And this in the codebehind:

   Protected Sub FormView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormView1.DataBound
        If FormView1.CurrentMode = FormViewMode.ReadOnly Then
            Dim StatusLabel As Label = CType(FormView1.FindControl("Status"), Label)
            Dim StatusImage As Image = CType(FormView1.FindControl("Image1"), Image)
            If StatusLabel.Text = "1" Then
                StatusImage.ImageUrl = "~/images/StatusGreen.png"
            ElseIf StatusLabel.Text = "2" Then
                StatusImage.ImageUrl = "~/images/StatusYellow.png"
            ElseIf StatusLabel.Text = "3" Then
                StatusImage.ImageUrl = "~/images/StatusRed.png"
            Else
                StatusImage.ImageUrl = "~/images/arrow007.gif"
            End If
        End If

I don't get an error, but the label show the DateKeyName instead of the value of the field.  I think I need to change <%# Bind("keyApplicantID") %> back to <%# Bind("Status") %>

Yeah, change it to Eval("Status")
Bind() is two way data binding, you don't need that in the item template, so use Eval, which is read only data binding.
That worked.  I changed the <%# Bind("keyApplicantID") %> back to <%# Bind("Status") %>
and now my label shows the little colored Icons to represent the status.  :-)
Oh, yeah, I see.  I wouldn't need two way binding in the ItemTemplate.  I'll change that to Eval.

Dang, these GridView and FormView controls are tricking to work with.  I'm sure they are still a lot easier than coding something like that before .Net!
Thank you very much for your help this late at night!
Yes they are, way easier.  The old standard would require 3 pages typically.  

user_view.asp
user_edit.asp
user_insert.asp

You had to create objects like this
Set objRecordset = Server.CreateObject("ADODB.Recordset")

and then step through the recordsets
objRecordset.Open strSQL, DB_CONNECTIONSTRING, adOpenKeyset, adLockPessimistic, adCmdText
If Not objRecordset.EOF Then
objRecordset.MoveFirst

It was a mess compared to .NET ;)
I feel bad complaining about what a pain in the @$$ the .Net FormView and GridViews are.  But, I'm just learning, so they do have some frustrating "features" that I haven't learned to use properly yet.  ;-)

Thank you again.  Now I just need to get rid of that extra item in my radioButtonList due to the "AppendDataBoundItems='True' " I had to use to get it to work.