Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Problem adding ListItems to RadioButtonList in EditItemTemplate of a FormView

Posted on 2009-02-18
12
Medium Priority
?
1,839 Views
Last Modified: 2013-11-07
I put a RadioButtonList in the EditItemTemplate of a FormView and I can't make it behave.  With the code below I get an extra item Appended to the ListItems I have hard coded in.  I know that's because of the "AppendDataBoundItems='True' ", but without that I get the error below.

I've tried removing various (every) combinations of these items:
                         SelectedValue='<%# Bind("Status") %>'
                         AppendDataBoundItems="True"

                        <asp:ListItem Value="1">Complete</asp:ListItem>
                        <asp:ListItem Value="2">Pending</asp:ListItem>
                        <asp:ListItem Value="3">Ineligable</asp:ListItem>

... but none resulted in giving me the three or four correct ListItems displayed.  I always either got the extra one or only the current selection plus "None".

I know from googling that there's a way to hook this up all programatically, but I really need an example of the VB code to do that it that the best option.  I hope someone has tackled and solved this.  Thanks for any help.


"Error below":
'radStatus' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value
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.ArgumentOutOfRangeException: 'radStatus' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace:


[ArgumentOutOfRangeException: 'radStatus' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value]
   System.Web.UI.WebControls.ListControl.PerformDataBinding(IEnumerable dataSource) +1604142
   System.Web.UI.WebControls.ListControl.OnDataBinding(EventArgs e) +107
   System.Web.UI.WebControls.ListControl.PerformSelect() +34
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   System.Web.UI.Control.DataBindChildren() +211
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +211
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +211
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102
   System.Web.UI.Control.DataBind() +15
   System.Web.UI.Control.DataBindChildren() +211
   System.Web.UI.Control.DataBind(Boolean raiseOnDataBinding) +102
   System.Web.UI.WebControls.FormView.CreateChildControls(IEnumerable dataSource, Boolean dataBinding) +1461
   System.Web.UI.WebControls.CompositeDataBoundControl.PerformDataBinding(IEnumerable data) +57
   System.Web.UI.WebControls.FormView.PerformDataBinding(IEnumerable data) +12
   System.Web.UI.WebControls.DataBoundControl.OnDataSourceViewSelectCallback(IEnumerable data) +114
   System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) +31
   System.Web.UI.WebControls.DataBoundControl.PerformSelect() +142
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +73
   System.Web.UI.WebControls.FormView.DataBind() +4
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +82
   System.Web.UI.WebControls.FormView.EnsureDataBound() +166
   System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +22
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
<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>

Open in new window

RadioButtonList4.jpg
RadioButtonList3.jpg
RadioButtonListError.jpg
0
Comment
Question by:megnin
  • 8
  • 4
12 Comments
 
LVL 11

Expert Comment

by:jmwheeler
ID: 23672608
Since you are using the "Bind" command you need to make sure your DropDownList contains all of the values that might be returned in "keyApplicantID".  The items you added start with a value of 0 but the database ID might start at 1.  

Can you post the data returned by SqlDatasource1?
0
 
LVL 11

Expert Comment

by:jmwheeler
ID: 23672626
On a side note: you misspelled ineligible as ineligable
0
 
LVL 1

Author Comment

by:megnin
ID: 23693951
The default value in the "Status" field of my database is "0" and I've added three dummy records with values of 1, 2 and 3 to make sure that all four selections were represented in the database.

<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>

I'm at home, but I can post the SqlDatasource1 date a little later.

I'm open to any solution, maybe hooking it up programatically in VB?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 11

Expert Comment

by:jmwheeler
ID: 23694613
Is this inside another control (GridView, Repeater, etc.)?  Can you post the entire page code?
0
 
LVL 1

Author Comment

by:megnin
ID: 23707081
No, it's not inside any other control.  It's just the FormView control.  There may be another control on the page with it but neither are nested inside the other.  They may be inside an UpdatePanel.
I'll post the page code when I get to work tomorrow.
0
 
LVL 1

Author Comment

by:megnin
ID: 23710864
Here's the .aspx page code:

<%@ 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;
      }
.moveImageLeft
{
      position:relative;
      left:-50px;
}

      .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:right; position:relative; left:-1em;">
      <asp:Button ID="btnLogOff" runat="server" Text="Log Off" Height="25px" />
      <br />
<div style="text-align:center; font-style:italic; color:Fuchsia; font-size:small; margin-top:1em; position:relative; left:-1.5em;">
      Log Off when you<br />
      leave the computer<br />
      for <span class="underlined">any</span> reason!
</div>
      
</div>
<div style="float:left; position:relative; left:2em;">
<span style="font-style:italic; color:Silver;">Press "F5" to refresh your login name.</span>
<br />
<br />
      <asp:Label ID="lblUserName" runat="server" Text="Not Logged In"></asp:Label>
      <br />
      <br />

</div>

<div style="margin:3px auto 5px auto; width:20%;">
        <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
                                      DataSourceID="SqlDataSource2"
                                      DataTextField="NameAndSSN"
                                      DataValueField="keyApplicantID"
                                      CssClass="moveDropDownLeft"
                                      >
        </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 > 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="Double" BorderWidth="1px"
            CellPadding="3" GridLines="Both"
            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" MaxLength="3" Width="30px"  />
                  </td>
                  </tr>
                  <tr>
                  <td>
                Info 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="15px" />
                  </td>
                  </tr>
                  <tr>
                  <td>
                Paperwork 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>
<%--
                                    <asp:RadioButtonList ID="radStatus" runat="server" RepeatDirection="Vertical"
                                                 RepeatLayout="Flow"
                                                 DataSourceID="SqlDataSource1"
 
                                                 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" />--%>
                                    <asp:Label ID="Status" runat="server" Visible="false" Text='<%# Eval("Status") %>'></asp:Label>
                                    <asp:Image ID="Image1" runat="server" ImageUrl="~/images/StatusUnk1.png" CssClass="moveImageLeft" />
                              </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>
<br />
            <div style="text-align:left; border-style:double; border-color:Aqua; padding: 10px; width:65%; margin-left:auto; margin-right:auto;">
                  Date of Birth must be on or AFTER 06/09/90 AND BEFORE or on 06/8/93.<br />
                  If Name, DOB, SSN, Address, Phone and Income are verified correct, then check the "Info Verified" check box.<br />
                  If they need to bring something back or are not all done with the paperwork then select "Pending".<br />
                  If they have brought all their paperwork in and it's all correct and complete then select "Complete".<br />
                  If they have been determined to be Ineligable, then select "Ineligable".<br />
                  Ignor the bottom selection button.  It only shows the current value.
<br />
<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>

and the .aspx.vb code behind:
 
Imports System.Data
Imports System.Data.SqlClient
Imports System.Web.UI.WebControls
Imports System.Web.UI.Page
 
Partial Class Applicant_Verification
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        lblUserName.Text = "Logged in as: " & Session("MonitorID") & "  <br /> Editing Record: " & DropDownList1.SelectedValue.ToString
        If DropDownList1.SelectedValue Is Nothing Then
            FormView1.Enabled = False
        Else
            FormView1.Enabled = True
        End If
        If Session("MonitorID") Is Nothing Then
            Response.Redirect("https://syep.wf1broward.com/Applicant_Verification_Login.aspx")
            '    FormView1.Enabled = False
            'Else
            '    FormView1.Enabled = True
        End If
        'If Not Page.IsPostBack Then
        '    Dim saveButton As Button = CType(FormView1.FindControl("updatebutton"), Button)
        '    Dim verifiedCheckBox As CheckBox = CType(FormView1.FindControl("CheckBox1"), CheckBox)
        '    If verifiedCheckBox.Checked = False Then
        '        saveButton.Enabled = False
        '    Else
        '        saveButton.Enabled = True
        '    End If
        'End If
        ' Crap --------------------
        '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
 
        'Session("MonitorID") = Session("MonitorID")
 
        'Response.Write("Current Session timeout value is " & Session.Timeout & " minutes.")
 
 
    End Sub
 
    Protected Sub UpdateButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        'Call SendMonitorIDToApplicants()
        Call RunStoredProcedures()
    End Sub
 
    Protected Sub SendMonitorIDToApplicants()
        '|----------------------------------------------------------------------|
        '| Add MonitorID to Applicants Table "LastEditedBy" field               |
        '|                                                                      |
        '|----------------------------------------------------------------------|
 
        Dim DBConn As New SqlConnection("UID=dmegnin;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SYEP2007;Data Source=BETASERVE;Packet Size=4096;")
        Dim DBCmd As New SqlCommand
        Dim DBAdap As New SqlDataAdapter
        'Dim DS As New DataSet   ' It doesn't look like I'm using a DataSet anywhere. ????
        DBConn.Open()
 
        Try
            'Add Insert Statement 
            'DBCmd = New SqlCommand("SET NOCOUNT ON; INSERT INTO JobTitles(keyWorksiteID,keyEmployerID,txtWorksiteJobTitle,txtWorksiteJobTitlePositionsNumber,ddlDressCode,ddlIndoorOutdoor,ddlWorkHours,cbWeekdays,cbSaturdays,cbSundays,ddlBackgroundCheck,txtJobDescriptionPrim1,txtJobDescriptionPrim2,txtJobDescriptionPrim3,txtJobDescriptionPrim4,txtJobDescriptionPrim5,txtJobDescriptionSec1,txtJobDescriptionSec2,txtJobDescriptionSec3,txtJobDescriptionSec4,txtJobDescriptionSec5,ApplicationDatePosition) VALUES (@txtForeignKeyPosWorksiteID,@txtForeignKeyPosEmployerID,@txtWorksiteJobTitle,@txtWorksiteJobTitlePositionsNumber,@ddlDressCode,@ddlIndoorOutdoor,@ddlWorkHours,@cbWeekdays,@cbSaturdays,@cbSundays,@ddlBackgroundCheck,@txtJobDescriptionPrim1,@txtJobDescriptionPrim2,@txtJobDescriptionPrim3,@txtJobDescriptionPrim4,@txtJobDescriptionPrim5,@txtJobDescriptionSec1,@txtJobDescriptionSec2,@txtJobDescriptionSec3,@txtJobDescriptionSec4,@txtJobDescriptionSec5,GetDate()); Select SCOPE_IDENTITY()", DBConn)
            DBCmd = New SqlCommand("UPDATE Applicants SET(LastUpdatedBy, DateUpdated) VALUES (@LastUpdatedBy, getdate())", DBConn)
            'Add Database Parameters
            'keyApplicantIDLabel1
            'DBCmd.Parameters.Add("@txtPriKeyPositionID", SqlDbType.Int).Value = txtPriKeyPositionID.Text
            DBCmd.Parameters.Add("@LastUpdatedBy", SqlDbType.VarChar).Value = Session("MonitorID").ToString()
            DBCmd.Parameters.Add("@LastUpdatedBy", SqlDbType.VarChar).Value = Session("MonitorID").ToString()
            'DBCmd.Parameters.Add("@txtForeignKeyPosEmployerID", SqlDbType.Int).Value = Session("eKey").ToString() ' txtForeignKeyPosEmployerID.Text
            DBCmd.ExecuteNonQuery()
            'Dim priKeyJobTitles As Integer = DBCmd.ExecuteScalar()
 
            'Response.Write(priKeyJobTitles)
            'Cache("jKey") = priKeyJobTitles.ToString  'I don't know if I'll need this.  Maybe for a Confirmation Page?
 
        Catch exp As Exception
            Response.Write(exp)
        End Try
 
        'Close Database connection 
        'and Dispose Database objects 
        DBCmd.Dispose()
        DBAdap.Dispose()
        DBConn.Close()
        DBConn = Nothing
 
    End Sub
 
    Protected Sub RunStoredProcedures()
        'Run stored procedures to update JobTitles with current Employer Name, Worksite Name, City, Zip, Positions Available and Positions Taken
        Dim sConnStr As String = "UID=dmegnin;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=SYEP2007;Data Source=BETASERVE;Packet Size=4096;"
        Dim cnBKTest As New SqlConnection(sConnStr)
        Dim cmdTest As New SqlCommand("sp_Update_Applicants_MonitorLastUpdated", cnBKTest)
        ' See here for how to run a collection of stored procedures
        ' http://www.dotnetjunkies.ddj.com/Article/9AE62C44-3841-4687-B906-2F6D4A5A4622.dcik
 
        cmdTest.CommandType = Data.CommandType.StoredProcedure
 
        cmdTest.Parameters.Add(New SqlParameter("@MonitorID", Data.SqlDbType.VarChar, 50))
        cmdTest.Parameters("@MonitorID").Value = Session("MonitorID").ToString()
 
        cmdTest.Parameters.Add(New SqlParameter("@keyApplicantID", Data.SqlDbType.VarChar, 10))
        cmdTest.Parameters("@keyApplicantID").Value = DropDownList1.SelectedValue.ToString
 
        cnBKTest.Open()
        cmdTest.ExecuteNonQuery()
        cnBKTest.Close()
    End Sub
 
    Protected Sub btnLogOff_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogOff.Click
        Response.Redirect("https://syep.wf1broward.com/Applicant_Verification_Login.aspx")
    End Sub
    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
        'Test here to put in Page_Load
        'If Not Page.IsPostBack Then
        '    Dim saveButton As Button = CType(FormView1.FindControl("updatebutton"), Button)
        '    Dim verifiedCheckBox As CheckBox = CType(FormView1.FindControl("CheckBox1"), CheckBox)
        '    If verifiedCheckBox.Checked = False Then
        '        saveButton.Enabled = False
        '    Else
        '        saveButton.Enabled = True
        '    End If
        'End If
 
    End Sub
 
 
    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
 
        'If Not Page.IsPostBack Then
        '    MyDropDownList.DataTextField = "FieldOne"
        '    MyDropDownList.DataValueField = "FieldTwo"
        '    MyDropDownList.DataBind()
        '    MyDropDownList.Items.Insert(0, '-- Select One Item --')
        'End If
 
 
        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/StatusUnk1.png"
            End If
        End If
 
 
    End Sub
End Class

Open in new window

0
 
LVL 11

Accepted Solution

by:
jmwheeler earned 2000 total points
ID: 23711091
Take the following lines off of your RadioButtonLists:

DataSourceID="SqlDataSource1"
DataTextField="Status"
DataValueField="keyApplicantID"
AppendDataBoundItems = "True"

Since you are specifying the values for your drop down you don't need a data source you just need the SelectedValue.
0
 
LVL 1

Author Comment

by:megnin
ID: 23711110
Will it still update when changes are made?
0
 
LVL 1

Author Comment

by:megnin
ID: 23711144
Oh, I guess so, It's still go the SelectedValue='<%# Bind("Status") %>' I'm trying it now.
0
 
LVL 1

Author Comment

by:megnin
ID: 23711181
That was so simple.   It takes someone who really knows what they are doing to know what parts are *NOT* needed.

Thank you so much!  I've looked at a dozen solutions on the web that didn't work and this was the simplest of all and the only one that did work.
0
 
LVL 1

Author Closing Comment

by:megnin
ID: 31548260
Thanks again for a most elegant solution.
0
 
LVL 1

Author Comment

by:megnin
ID: 23711221
Oh, I corrected the spelling error, too.  Thanks for catching that, too.  ;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question