Gridview Hyperlink

I am modifying a website that has a gridview, that shows data from a database which has been entered from a form.
If you click on an item on the gridview, the webpage takes me into the webform as it was filled out.

I have changed what database is shown on the gridview, but when I click on the item, it shows me the details of the old database, now how do i tell it what database to check?

Here is the code im modifying.
<asp:GridView ID="GridView3" runat="server" AutoGenerateColumns="False" CellPadding="4"
                        DataSourceID="SqlDataSource2" Font-Underline="False" ForeColor="Black" GridLines="Horizontal"
                        Width="100%">
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <Columns>
                            <asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="approve.aspx?Id={0}"
                                DataTextField="FullName" HeaderText="Visitor Name">
                                <ControlStyle Font-Bold="True" ForeColor="Tomato" />
                            </asp:HyperLinkField>
                            <asp:BoundField DataField="Company" HeaderText="Organization" SortExpression="Company" />
                            <asp:TemplateField HeaderText="Dates of Access">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("DateOfAccessFromM") %>'></asp:Label>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("DateofAccessFromD") %>'></asp:Label>,
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("DateOfAccessFromY") %>'></asp:Label>
                                    -
                                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("DateOfAccessToM") %>'></asp:Label>
                                    <asp:Label ID="Label5" runat="server" Text='<%# Eval("DateOfAccessToD") %>'></asp:Label>,
                                    <asp:Label ID="Label6" runat="server" Text='<%# Eval("DateOfAccessToY") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Hours">
                                <ItemTemplate>
                                    <asp:Label ID="Label7" runat="server" Text='<%# Eval("TimeOfAccessFrom") %>'></asp:Label>
                                    -
                                    <asp:Label ID="Label8" runat="server" Text='<%# Eval("TimeOfAccessTo") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Location">
                                <ItemTemplate>
                                    <asp:Label ID="locationLabel" runat="server" Text='<%# Location( (int) Eval("Location_Id") ) 

%>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <RowStyle BackColor="#EFF3FB" Font-Underline="False" HorizontalAlign="Left" />
                        <EditRowStyle BackColor="#2461BF" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
                        <AlternatingRowStyle BackColor="White" />
                    </asp:GridView>
                   
 <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                        SelectCommand="SELECT Id, LastName, FirstName, Company, Escort, DateofAccessFromD, DateOfAccessFromM, 

DateOfAccessFromY, DateOfAccessToM, DateOfAccessToD, DateOfAccessToY, Location_Id, TimeOfAccessFrom, TimeOfAccessTo, RequestDate, ApprovedBy, 

LastName + ', ' + FirstName AS FullName FROM dbo.Visitors2 WHERE (AmbApproved IS NULL)">

Open in new window

Vx_ChemicalAsked:
Who is Participating?
 
Vx_ChemicalConnect With a Mentor Author Commented:
I forgot to change the which code behind file there was linked to.
0
 
guru_samiCommented:
make sure you DataSource is using correct connectionstring ...e.g.
ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"

Also you are sharing the GV code but not the form that has the problem. So not sure what page is facing problem. And do you mean approve.aspx?Id={0} page ? If so we need to see the code on that page.
0
 
Vx_ChemicalAuthor Commented:
here is code from the approve page


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="approve.aspx.cs" MaintainScrollPositionOnPostback="true" Inherits="visitoraccess_Default" %>

<%@ Register Src="../usercontrols/rsoVisitorMenu.ascx" TagName="rsoVisitorMenu" TagPrefix="uc7" %>

<%@ Register Src="~/usercontrols/headerMenu.ascx" TagName="headerMenu" TagPrefix="uc5" %>

<%@ Register Src="~/usercontrols/headerAdminMenu.ascx" TagName="headerAdminMenu" TagPrefix="uc4" %>

<%@ Register Src="~/usercontrols/loginControl.ascx" TagName="loginControl" TagPrefix="uc1" %>
<%@ Register Src="~/usercontrols/mainMenu.ascx" TagName="mainMenu" TagPrefix="uc3" %>

<%@ Register Src="~/usercontrols/footermenu.ascx" TagName="footermenu" TagPrefix="uc2" %>
<!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 id="Head1" runat="server">
    <title>Copenhagen - Intranet</title>
    <link href="../Styles.css" rel="stylesheet" type="text/css" />
    
</head>
<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0">
    <form id="form1" runat="server">
        <div>
            <table id="header" cellpadding="0" cellspacing="0" width="100%" border="0">
                <tr>
                    <td colspan="1" style="height: 20px; width: 367px;" bgcolor="#7a92cb" bordercolor="#000000">
                        <asp:Image ID="Image2" runat="server" ImageUrl="~/images/mermaidheader1.gif" /></td>
                    <td width="20%" style="filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#ACBCE3', endColorStr='#7A92CB', gradientType='1'); height: 20px;">
                    </td>
                    <td align="right" bgcolor="#7a92cb" style="height: 20px;" valign="top" bordercolor="#000000">
                        <asp:Image ID="Image3" runat="server" ImageUrl="~/images/embassyheader.gif" /></td>
                </tr>
                <tr>
                    <td colspan="0" style="height: 42px; width: 367px;" valign="top" bgcolor="#bbc6de"
                        bordercolor="#000000">
                        <asp:Image ID="Image1" runat="server" ImageUrl="~/images/headermain.gif" /></td>
                    <td width="20%" style="filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#D5DCEB', endColorStr='#BCC6DE', gradientType='1');
                        height: 42px;">
                    </td>
                    <td bgcolor="#bbc6de" style="height: 42px; font-weight: bold; font-size: 7pt; color: #000000;
                        font-family: Verdana, Arial, 'Arial Black';" valign="bottom" align="right">
                        <uc1:loginControl ID="LoginControl1" runat="server" />
                    </td>
                </tr>
                <tr bgcolor="999999" height="1px">
                    <td colspan="3" style="height: 1px">
                    </td>
                </tr>
                <tr bordercolor="#000000" bgcolor="f1f1f1" class="menu">
                    <td colspan="2" >
                        <uc5:headerMenu ID="HeaderMenu1" runat="server" />
                    </td>
                    <td colspan="1" align="right">
                        <uc4:headerAdminMenu ID="HeaderAdminMenu1" runat="server" />
                        &nbsp;</td>
                </tr>
                <tr bgcolor="999999" height="1px">
                    <td colspan="3">
                    </td>
                </tr>
            </table>
        </div>
        <table id="main" cellpadding="0" cellspacing="0" width="100%" border="0">
            <tr>
                <td style="width: 160px; height: 500px; padding-right: 5px; padding-left: 5px; padding-bottom: 5px; margin: 5px; padding-top: 5px;" valign="top" bgcolor="#f1f1f1">
                    <table border="1" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="width: 150px; height: 140px; padding-top: 5px;" valign="top">
                                <uc7:rsoVisitorMenu ID="RsoVisitorMenu1" runat="server" />
                            </td>
                        </tr>
                    </table>
                </td>
                <td style="width: auto; padding-left: 5px; padding-top: 5px;" valign="top">
                <h1>
                        <br />
                    RSO - Approve / Edit Request
                    <hr /></h1>
                    &nbsp;<br />
                    &nbsp;<table style="font-weight: bold; font-size: 8pt; width: 655px; height: 60px">
                        <tr>
                            <td align="center" style="width: 651px; height: 56px">
                                <fieldset>
                                    <legend align="left">Visitor Information</legend>
                                    <br />
                                    <table>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Last Name:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:TextBox ID="lastNameTxtBox" runat="server"></asp:TextBox></td>
                                            <td align="left" style="width: 147px">
                                                First Name:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:TextBox ID="firstNameTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Organization:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:TextBox ID="companyTxtBox" runat="server"></asp:TextBox></td>
                                            <td align="left" style="width: 147px">
                                                Citizenship:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:TextBox ID="citizenshipTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Vehicle:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:DropDownList ID="vehicleDropDown" runat="server">
                                                    <asp:ListItem>No</asp:ListItem>
                                                    <asp:ListItem>Yes</asp:ListItem>
                                                </asp:DropDownList></td>
                                            <td align="left" style="width: 147px">
                                                Vehicle License Plate:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:TextBox ID="vehicleLicenTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Location of Visit:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:DropDownList ID="locationDropDown" runat="server" DataSourceID="locationSrc"
                                                    DataTextField="Location" DataValueField="Id" Width="155px">
                                                </asp:DropDownList></td>
                                            <td align="left" style="width: 147px">
                                                Section:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:DropDownList ID="visitSecDropDown" runat="server" DataSourceID="officesSrc"
                                                    DataTextField="OfficeName" DataValueField="OfficeName" Width="155px">
                                                </asp:DropDownList></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Reason for Access:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:DropDownList ID="reasonDropDown" runat="server" DataSourceID="reasonSrc" DataTextField="Reason"
                                                    DataValueField="Id" Width="155px">
                                                </asp:DropDownList></td>
                                            <td align="left" style="width: 147px">
                                                Special Requirements:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:TextBox ID="specialReqTxtBox" runat="server" MaxLength="200"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 160px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 147px; height: 15px">
                                                Clearance:</td>
                                            <td align="left" style="width: 100px; height: 15px">
                                                <asp:DropDownList ID="clearDropDown" runat="server" >
                                                    <asp:ListItem>No</asp:ListItem>
                                                    <asp:ListItem>Yes</asp:ListItem>
                                                </asp:DropDownList></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 160px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 147px; height: 15px">
                                                ECC Cable No#:</td>
                                            <td align="left" style="width: 100px; height: 15px">
                                                <asp:TextBox ID="eccTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" colspan="2">
                                                Please provide specific reason:</td>
                                            <td align="left" style="width: 147px">
                                            </td>
                                            <td align="left" style="width: 100px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" colspan="2">
                                                <asp:TextBox ID="otherReasonTxtBox" runat="server" TextMode="MultiLine" Width="300px"></asp:TextBox></td>
                                            <td align="left" style="width: 147px">
                                            </td>
                                            <td align="left" style="width: 100px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" colspan="2" style="height: 15px">
                                            </td>
                                            <td align="left" style="width: 147px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 100px; height: 15px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Date(s) of Visit From:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:DropDownList ID="fromMonthDropDown" runat="server" Width="50px">
                                                    <asp:ListItem></asp:ListItem>
                                                    <asp:ListItem Value="1">Jan</asp:ListItem>
                                                    <asp:ListItem Value="2">Feb</asp:ListItem>
                                                    <asp:ListItem Value="3">Mar</asp:ListItem>
                                                    <asp:ListItem Value="4">Apr</asp:ListItem>
                                                    <asp:ListItem Value="5">May</asp:ListItem>
                                                    <asp:ListItem Value="6">June</asp:ListItem>
                                                    <asp:ListItem Value="7">July</asp:ListItem>
                                                    <asp:ListItem Value="8">Aug</asp:ListItem>
                                                    <asp:ListItem Value="9">Sep</asp:ListItem>
                                                    <asp:ListItem Value="10">Oct</asp:ListItem>
                                                    <asp:ListItem Value="11">Nov</asp:ListItem>
                                                    <asp:ListItem Value="12">Dec</asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:DropDownList ID="fromDayDropDown" runat="server" Width="42px">
                                                    <asp:ListItem></asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:DropDownList ID="fromYearDropDown" runat="server" Width="55px">
                                                    <asp:ListItem></asp:ListItem>
                                                </asp:DropDownList></td>
                                            <td align="left" colspan="2">
                                                To:
                                                <asp:DropDownList ID="toMonthDropDown" runat="server" Width="50px">
                                                    <asp:ListItem></asp:ListItem>
                                                    <asp:ListItem Value="1">Jan</asp:ListItem>
                                                    <asp:ListItem Value="2">Feb</asp:ListItem>
                                                    <asp:ListItem Value="3">Mar</asp:ListItem>
                                                    <asp:ListItem Value="4">Apr</asp:ListItem>
                                                    <asp:ListItem Value="5">May</asp:ListItem>
                                                    <asp:ListItem Value="6">June</asp:ListItem>
                                                    <asp:ListItem Value="7">July</asp:ListItem>
                                                    <asp:ListItem Value="8">Aug</asp:ListItem>
                                                    <asp:ListItem Value="9">Sep</asp:ListItem>
                                                    <asp:ListItem Value="10">Oct</asp:ListItem>
                                                    <asp:ListItem Value="11">Nov</asp:ListItem>
                                                    <asp:ListItem Value="12">Dec</asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:DropDownList ID="toDayDropDown" runat="server" Width="42px">
                                                    <asp:ListItem></asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:DropDownList ID="toYearDropDown" runat="server" Width="55px">
                                                    <asp:ListItem></asp:ListItem>
                                                </asp:DropDownList></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px; height: 10px">
                                            </td>
                                            <td align="left" style="width: 160px; height: 10px">
                                            </td>
                                            <td align="left" colspan="2" style="height: 10px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px; height: 10px">
                                                Time of Visit From:</td>
                                            <td align="left" style="width: 160px; height: 10px">
                                                <asp:DropDownList ID="timeFromDropDown" runat="server" DataSourceID="timeSrc" DataTextField="hour"
                                                    DataValueField="hour">
                                                    <asp:ListItem>08:00</asp:ListItem>
                                                </asp:DropDownList>&nbsp; To: &nbsp;<asp:DropDownList ID="timeToDropDown" runat="server"
                                                    DataSourceID="timeSrc" DataTextField="hour" DataValueField="hour">
                                                    <asp:ListItem>16:00</asp:ListItem>
                                                </asp:DropDownList></td>
                                            <td align="left" colspan="2" style="height: 10px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                            </td>
                                            <td align="left" colspan="2" valign="middle">
                                            </td>
                                            <td align="left" style="width: 100px" valign="middle">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                            </td>
                                            <td align="left" style="width: 160px">
                                            </td>
                                            <td align="left" style="width: 147px">
                                            </td>
                                            <td align="left" style="width: 100px">
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                                <br />
                                <fieldset>
                                    <legend align="left">Requesting Office</legend>
                                    <br />
                                    <table>
                                        <tr>
                                            <td align="left" style="width: 145px">
                                                Requester Name:</td>
                                            <td style="width: 160px">
                                                <asp:TextBox ID="requesterNameTxtBox" runat="server"></asp:TextBox></td>
                                            <td align="left" style="width: 150px">
                                                Escort Name:</td>
                                            <td style="width: 100px">
                                                <asp:TextBox ID="escortNameTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 145px; height: 5px">
                                            </td>
                                            <td style="width: 160px; height: 5px">
                                            </td>
                                            <td align="left" style="width: 150px; height: 5px">
                                            </td>
                                            <td style="width: 100px; height: 5px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 145px">
                                                Requesting Office:</td>
                                            <td style="width: 160px">
                                                <asp:DropDownList ID="officeDropDown" runat="server" DataSourceID="officeSrc" DataTextField="RequestingOffice"
                                                    DataValueField="Id" Width="155px">
                                                </asp:DropDownList></td>
                                            <td align="left" style="width: 150px">
                                            </td>
                                            <td style="width: 100px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 145px; height: 5px">
                                            </td>
                                            <td style="width: 160px; height: 5px">
                                            </td>
                                            <td align="left" style="width: 150px; height: 5px">
                                            </td>
                                            <td style="width: 100px; height: 5px">
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                                <br />
                                <fieldset>
                                    <legend align="left">RSO Use Only</legend>
                                    <br />
                                    <table>
                                        <tr>
                                            <td align="left" style="width: 156px">
                                                Date Received:</td>
                                            <td align="left" style="width: 157px">
                                                <asp:Label ID="dateReceiveLabel" runat="server" Font-Bold="False"></asp:Label></td>
                                            <td align="left" style="width: 239px">
                                                Badge to issue: &nbsp; &nbsp;
                                                <asp:DropDownList ID="badgeDropDown" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
                                                    <asp:ListItem>Select</asp:ListItem>
						    <asp:ListItem>AccessDenied</asp:ListItem>
                                                    <asp:ListItem>RED</asp:ListItem>
                                                    <asp:ListItem>BLUE</asp:ListItem>
                                                    <asp:ListItem>YELLOW</asp:ListItem>
                                                </asp:DropDownList><asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="badgeDropDown"
                                                    ErrorMessage="Please select a Badge Type" Operator="NotEqual" ValueToCompare="Select">*</asp:CompareValidator></td>
                                            <td rowspan="6" style="width: 75px" valign="top">
                                                <asp:Image ID="badgeImage" runat="server" Visible="False" /></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 156px; height: 5px">
                                            </td>
                                            <td align="left" style="width: 157px; height: 5px">
                                            </td>
                                            <td align="left" style="width: 239px; height: 5px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 156px">
                                                Request Status:</td>
                                            <td align="left" style="width: 157px">
                                                <asp:DropDownList ID="statusDropDown" runat="server">
                                                    <asp:ListItem>Pending</asp:ListItem>
                                                    <asp:ListItem Value="1">Approved</asp:ListItem>
                                                    <asp:ListItem Value="0">Not Approved</asp:ListItem>
                                                </asp:DropDownList><asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="statusDropDown"
                                                    ErrorMessage="Please select Status" Operator="NotEqual" ValueToCompare="Pending">*</asp:CompareValidator></td>
                                            <td align="left" style="width: 239px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 156px">
                                            </td>
                                            <td style="width: 157px">
                                            </td>
                                            <td align="left" style="width: 239px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 156px" valign="top">
                                                RSO Comment:</td>
                                            <td align="left" colspan="2" valign="top">
                                                <asp:TextBox ID="RsoCommentTxtBox" runat="server" TextMode="MultiLine" Width="250px"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="right" style="width: 156px" valign="bottom">
                                            </td>
                                            <td colspan="2" valign="bottom">
                                                <asp:Button ID="submitBtn" runat="server" OnClick="submitBtn_Click" Text="Save" />
                                                <asp:Button ID="delButton" runat="server" OnClick="delButton_Click" Text="Delete"
                                                    ValidationGroup="1" /></td>
                                        </tr>
                                        <tr>
                                            <td align="right" style="width: 156px" valign="bottom">
                                            </td>
                                            <td align="left" colspan="2" valign="bottom">
                                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                                            </td>
                                            <td rowspan="1" style="width: 75px" valign="top">
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                                <asp:SqlDataSource ID="countrySrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [Country]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="locationSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [Locations]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="reasonSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [ReasonForAccess]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="timeSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [Hour]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="officeSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [RequestingOffice]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="officesSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT [OfficeName] FROM [RequestingOffice] ORDER BY [Id] DESC"></asp:SqlDataSource>
                            </td>
                        </tr>
                    </table>
                </td>
                <td style="width: 100px">
                </td>
            </tr>
            <tr height="15px" class="footer">
                <td colspan="3" style="filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#7A92CB', endColorStr='#D5DCEB', gradientType='1');
                    height: 15px;">
                    <uc2:footermenu ID="Footermenu1" runat="server" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

Open in new window

0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
guru_samiCommented:
--->but when I click on the item, it shows me the details of the old database,
By that you mean the details on approve.aspx correct ?
I don't see any databinding on approve.aspx. How are you showing that details ? anything in code-behind.
Or may be can yo explain a bit more on the issue.
0
 
Vx_ChemicalAuthor Commented:
Mm i Will have look tomorrow when I am at work again
0
 
Vx_ChemicalAuthor Commented:
Here is my approve.aspx


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="approve.aspx.cs" MaintainScrollPositionOnPostback="true" Inherits="visitoraccess_Default" %>

<%@ Register Src="../usercontrols/rsoVisitorMenu.ascx" TagName="rsoVisitorMenu" TagPrefix="uc7" %>

<%@ Register Src="~/usercontrols/headerMenu.ascx" TagName="headerMenu" TagPrefix="uc5" %>

<%@ Register Src="~/usercontrols/headerAdminMenu.ascx" TagName="headerAdminMenu" TagPrefix="uc4" %>

<%@ Register Src="~/usercontrols/loginControl.ascx" TagName="loginControl" TagPrefix="uc1" %>
<%@ Register Src="~/usercontrols/mainMenu.ascx" TagName="mainMenu" TagPrefix="uc3" %>

<%@ Register Src="~/usercontrols/footermenu.ascx" TagName="footermenu" TagPrefix="uc2" %>
<!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 id="Head1" runat="server">
    <title>Copenhagen - Intranet</title>
    <link href="../Styles.css" rel="stylesheet" type="text/css" />
    
</head>
<body bottommargin="0" topmargin="0" leftmargin="0" rightmargin="0">
    <form id="form1" runat="server">
        <div>
            <table id="header" cellpadding="0" cellspacing="0" width="100%" border="0">
                <tr>
                    <td colspan="1" style="height: 20px; width: 367px;" bgcolor="#7a92cb" bordercolor="#000000">
                        <asp:Image ID="Image2" runat="server" ImageUrl="~/images/mermaidheader1.gif" /></td>
                    <td width="20%" style="filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#ACBCE3', endColorStr='#7A92CB', gradientType='1'); height: 20px;">
                    </td>
                    <td align="right" bgcolor="#7a92cb" style="height: 20px;" valign="top" bordercolor="#000000">
                        <asp:Image ID="Image3" runat="server" ImageUrl="~/images/embassyheader.gif" /></td>
                </tr>
                <tr>
                    <td colspan="0" style="height: 42px; width: 367px;" valign="top" bgcolor="#bbc6de"
                        bordercolor="#000000">
                        <asp:Image ID="Image1" runat="server" ImageUrl="~/images/headermain.gif" /></td>
                    <td width="20%" style="filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#D5DCEB', endColorStr='#BCC6DE', gradientType='1');
                        height: 42px;">
                    </td>
                    <td bgcolor="#bbc6de" style="height: 42px; font-weight: bold; font-size: 7pt; color: #000000;
                        font-family: Verdana, Arial, 'Arial Black';" valign="bottom" align="right">
                        <uc1:loginControl ID="LoginControl1" runat="server" />
                    </td>
                </tr>
                <tr bgcolor="999999" height="1px">
                    <td colspan="3" style="height: 1px">
                    </td>
                </tr>
                <tr bordercolor="#000000" bgcolor="f1f1f1" class="menu">
                    <td colspan="2" >
                        <uc5:headerMenu ID="HeaderMenu1" runat="server" />
                    </td>
                    <td colspan="1" align="right">
                        <uc4:headerAdminMenu ID="HeaderAdminMenu1" runat="server" />
                        &nbsp;</td>
                </tr>
                <tr bgcolor="999999" height="1px">
                    <td colspan="3">
                    </td>
                </tr>
            </table>
        </div>
        <table id="main" cellpadding="0" cellspacing="0" width="100%" border="0">
            <tr>
                <td style="width: 160px; height: 500px; padding-right: 5px; padding-left: 5px; padding-bottom: 5px; margin: 5px; padding-top: 5px;" valign="top" bgcolor="#f1f1f1">
                    <table border="1" cellpadding="5" cellspacing="0">
                        <tr>
                            <td style="width: 150px; height: 140px; padding-top: 5px;" valign="top">
                                <uc7:rsoVisitorMenu ID="RsoVisitorMenu1" runat="server" />
                            </td>
                        </tr>
                    </table>
                </td>
                <td style="width: auto; padding-left: 5px; padding-top: 5px;" valign="top">
                <h1>
                        <br />
                    RSO - Approve / Edit Request
                    <hr /></h1>
                    &nbsp;<br />
                    &nbsp;<table style="font-weight: bold; font-size: 8pt; width: 655px; height: 60px">
                        <tr>
                            <td align="center" style="width: 651px; height: 56px">
                                <fieldset>
                                    <legend align="left">Visitor Information</legend>
                                    <br />
                                    <table>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Last Name:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:TextBox ID="lastNameTxtBox" runat="server"></asp:TextBox></td>
                                            <td align="left" style="width: 147px">
                                                First Name:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:TextBox ID="firstNameTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Organization:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:TextBox ID="companyTxtBox" runat="server"></asp:TextBox></td>
                                            <td align="left" style="width: 147px">
                                                Citizenship:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:TextBox ID="citizenshipTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Vehicle:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:DropDownList ID="vehicleDropDown" runat="server">
                                                    <asp:ListItem>No</asp:ListItem>
                                                    <asp:ListItem>Yes</asp:ListItem>
                                                </asp:DropDownList></td>
                                            <td align="left" style="width: 147px">
                                                Vehicle License Plate:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:TextBox ID="vehicleLicenTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Location of Visit:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:DropDownList ID="locationDropDown" runat="server" DataSourceID="locationSrc"
                                                    DataTextField="Location" DataValueField="Id" Width="155px">
                                                </asp:DropDownList></td>
                                            <td align="left" style="width: 147px">
                                                Section:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:DropDownList ID="visitSecDropDown" runat="server" DataSourceID="officesSrc"
                                                    DataTextField="OfficeName" DataValueField="OfficeName" Width="155px">
                                                </asp:DropDownList></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Reason for Access:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:DropDownList ID="reasonDropDown" runat="server" DataSourceID="reasonSrc" DataTextField="Reason"
                                                    DataValueField="Id" Width="155px">
                                                </asp:DropDownList></td>
                                            <td align="left" style="width: 147px">
                                                Special Requirements:</td>
                                            <td align="left" style="width: 100px">
                                                <asp:TextBox ID="specialReqTxtBox" runat="server" MaxLength="200"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 160px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 147px; height: 15px">
                                                Clearance:</td>
                                            <td align="left" style="width: 100px; height: 15px">
                                                <asp:DropDownList ID="clearDropDown" runat="server" >
                                                    <asp:ListItem>No</asp:ListItem>
                                                    <asp:ListItem>Yes</asp:ListItem>
                                                </asp:DropDownList></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 160px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 147px; height: 15px">
                                                ECC Cable No#:</td>
                                            <td align="left" style="width: 100px; height: 15px">
                                                <asp:TextBox ID="eccTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" colspan="2">
                                                Please provide specific reason:</td>
                                            <td align="left" style="width: 147px">
                                            </td>
                                            <td align="left" style="width: 100px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" colspan="2">
                                                <asp:TextBox ID="otherReasonTxtBox" runat="server" TextMode="MultiLine" Width="300px"></asp:TextBox></td>
                                            <td align="left" style="width: 147px">
                                            </td>
                                            <td align="left" style="width: 100px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" colspan="2" style="height: 15px">
                                            </td>
                                            <td align="left" style="width: 147px; height: 15px">
                                            </td>
                                            <td align="left" style="width: 100px; height: 15px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                                Date(s) of Visit From:</td>
                                            <td align="left" style="width: 160px">
                                                <asp:DropDownList ID="fromMonthDropDown" runat="server" Width="50px">
                                                    <asp:ListItem></asp:ListItem>
                                                    <asp:ListItem Value="1">Jan</asp:ListItem>
                                                    <asp:ListItem Value="2">Feb</asp:ListItem>
                                                    <asp:ListItem Value="3">Mar</asp:ListItem>
                                                    <asp:ListItem Value="4">Apr</asp:ListItem>
                                                    <asp:ListItem Value="5">May</asp:ListItem>
                                                    <asp:ListItem Value="6">June</asp:ListItem>
                                                    <asp:ListItem Value="7">July</asp:ListItem>
                                                    <asp:ListItem Value="8">Aug</asp:ListItem>
                                                    <asp:ListItem Value="9">Sep</asp:ListItem>
                                                    <asp:ListItem Value="10">Oct</asp:ListItem>
                                                    <asp:ListItem Value="11">Nov</asp:ListItem>
                                                    <asp:ListItem Value="12">Dec</asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:DropDownList ID="fromDayDropDown" runat="server" Width="42px">
                                                    <asp:ListItem></asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:DropDownList ID="fromYearDropDown" runat="server" Width="55px">
                                                    <asp:ListItem></asp:ListItem>
                                                </asp:DropDownList></td>
                                            <td align="left" colspan="2">
                                                To:
                                                <asp:DropDownList ID="toMonthDropDown" runat="server" Width="50px">
                                                    <asp:ListItem></asp:ListItem>
                                                    <asp:ListItem Value="1">Jan</asp:ListItem>
                                                    <asp:ListItem Value="2">Feb</asp:ListItem>
                                                    <asp:ListItem Value="3">Mar</asp:ListItem>
                                                    <asp:ListItem Value="4">Apr</asp:ListItem>
                                                    <asp:ListItem Value="5">May</asp:ListItem>
                                                    <asp:ListItem Value="6">June</asp:ListItem>
                                                    <asp:ListItem Value="7">July</asp:ListItem>
                                                    <asp:ListItem Value="8">Aug</asp:ListItem>
                                                    <asp:ListItem Value="9">Sep</asp:ListItem>
                                                    <asp:ListItem Value="10">Oct</asp:ListItem>
                                                    <asp:ListItem Value="11">Nov</asp:ListItem>
                                                    <asp:ListItem Value="12">Dec</asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:DropDownList ID="toDayDropDown" runat="server" Width="42px">
                                                    <asp:ListItem></asp:ListItem>
                                                </asp:DropDownList>
                                                <asp:DropDownList ID="toYearDropDown" runat="server" Width="55px">
                                                    <asp:ListItem></asp:ListItem>
                                                </asp:DropDownList></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px; height: 10px">
                                            </td>
                                            <td align="left" style="width: 160px; height: 10px">
                                            </td>
                                            <td align="left" colspan="2" style="height: 10px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px; height: 10px">
                                                Time of Visit From:</td>
                                            <td align="left" style="width: 160px; height: 10px">
                                                <asp:DropDownList ID="timeFromDropDown" runat="server" DataSourceID="timeSrc" DataTextField="hour"
                                                    DataValueField="hour">
                                                    <asp:ListItem>08:00</asp:ListItem>
                                                </asp:DropDownList>&nbsp; To: &nbsp;<asp:DropDownList ID="timeToDropDown" runat="server"
                                                    DataSourceID="timeSrc" DataTextField="hour" DataValueField="hour">
                                                    <asp:ListItem>16:00</asp:ListItem>
                                                </asp:DropDownList></td>
                                            <td align="left" colspan="2" style="height: 10px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                            </td>
                                            <td align="left" colspan="2" valign="middle">
                                            </td>
                                            <td align="left" style="width: 100px" valign="middle">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 143px">
                                            </td>
                                            <td align="left" style="width: 160px">
                                            </td>
                                            <td align="left" style="width: 147px">
                                            </td>
                                            <td align="left" style="width: 100px">
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                                <br />
                                <fieldset>
                                    <legend align="left">Requesting Office</legend>
                                    <br />
                                    <table>
                                        <tr>
                                            <td align="left" style="width: 145px">
                                                Requester Name:</td>
                                            <td style="width: 160px">
                                                <asp:TextBox ID="requesterNameTxtBox" runat="server"></asp:TextBox></td>
                                            <td align="left" style="width: 150px">
                                                Escort Name:</td>
                                            <td style="width: 100px">
                                                <asp:TextBox ID="escortNameTxtBox" runat="server"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 145px; height: 5px">
                                            </td>
                                            <td style="width: 160px; height: 5px">
                                            </td>
                                            <td align="left" style="width: 150px; height: 5px">
                                            </td>
                                            <td style="width: 100px; height: 5px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 145px">
                                                Requesting Office:</td>
                                            <td style="width: 160px">
                                                <asp:DropDownList ID="officeDropDown" runat="server" DataSourceID="officeSrc" DataTextField="RequestingOffice"
                                                    DataValueField="Id" Width="155px">
                                                </asp:DropDownList></td>
                                            <td align="left" style="width: 150px">
                                            </td>
                                            <td style="width: 100px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 145px; height: 5px">
                                            </td>
                                            <td style="width: 160px; height: 5px">
                                            </td>
                                            <td align="left" style="width: 150px; height: 5px">
                                            </td>
                                            <td style="width: 100px; height: 5px">
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                                <br />
                                <fieldset>
                                    <legend align="left">RSO Use Only</legend>
                                    <br />
                                    <table>
                                        <tr>
                                            <td align="left" style="width: 156px">
                                                Date Received:</td>
                                            <td align="left" style="width: 157px">
                                                <asp:Label ID="dateReceiveLabel" runat="server" Font-Bold="False"></asp:Label></td>
                                            <td align="left" style="width: 239px">
                                                Badge to issue: &nbsp; &nbsp;
                                                <asp:DropDownList ID="badgeDropDown" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList2_SelectedIndexChanged">
                                                    <asp:ListItem>Select</asp:ListItem>
						    <asp:ListItem>AccessDenied</asp:ListItem>
                                                    <asp:ListItem>RED</asp:ListItem>
                                                    <asp:ListItem>BLUE</asp:ListItem>
                                                    <asp:ListItem>YELLOW</asp:ListItem>
                                                </asp:DropDownList><asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="badgeDropDown"
                                                    ErrorMessage="Please select a Badge Type" Operator="NotEqual" ValueToCompare="Select">*</asp:CompareValidator></td>
                                            <td rowspan="6" style="width: 75px" valign="top">
                                                <asp:Image ID="badgeImage" runat="server" Visible="False" /></td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 156px; height: 5px">
                                            </td>
                                            <td align="left" style="width: 157px; height: 5px">
                                            </td>
                                            <td align="left" style="width: 239px; height: 5px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 156px">
                                                Request Status:</td>
                                            <td align="left" style="width: 157px">
                                                <asp:DropDownList ID="statusDropDown" runat="server">
                                                    <asp:ListItem>Pending</asp:ListItem>
                                                    <asp:ListItem Value="1">Approved</asp:ListItem>
                                                    <asp:ListItem Value="0">Not Approved</asp:ListItem>
                                                </asp:DropDownList><asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="statusDropDown"
                                                    ErrorMessage="Please select Status" Operator="NotEqual" ValueToCompare="Pending">*</asp:CompareValidator></td>
                                            <td align="left" style="width: 239px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 156px">
                                            </td>
                                            <td style="width: 157px">
                                            </td>
                                            <td align="left" style="width: 239px">
                                            </td>
                                        </tr>
                                        <tr>
                                            <td align="left" style="width: 156px" valign="top">
                                                RSO Comment:</td>
                                            <td align="left" colspan="2" valign="top">
                                                <asp:TextBox ID="RsoCommentTxtBox" runat="server" TextMode="MultiLine" Width="250px"></asp:TextBox></td>
                                        </tr>
                                        <tr>
                                            <td align="right" style="width: 156px" valign="bottom">
                                            </td>
                                            <td colspan="2" valign="bottom">
                                                <asp:Button ID="submitBtn" runat="server" OnClick="submitBtn_Click" Text="Save" />
                                                <asp:Button ID="delButton" runat="server" OnClick="delButton_Click" Text="Delete"
                                                    ValidationGroup="1" /></td>
                                        </tr>
                                        <tr>
                                            <td align="right" style="width: 156px" valign="bottom">
                                            </td>
                                            <td align="left" colspan="2" valign="bottom">
                                                <asp:ValidationSummary ID="ValidationSummary1" runat="server" />
                                            </td>
                                            <td rowspan="1" style="width: 75px" valign="top">
                                            </td>
                                        </tr>
                                    </table>
                                </fieldset>
                                <asp:SqlDataSource ID="countrySrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [Country]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="locationSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [Locations]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="reasonSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [ReasonForAccess]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="timeSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [Hour]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="officeSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT * FROM [RequestingOffice]"></asp:SqlDataSource>
                                <asp:SqlDataSource ID="officesSrc" runat="server" ConnectionString="<%$ ConnectionStrings:VisitorAccessConnectionString %>"
                                    SelectCommand="SELECT [OfficeName] FROM [RequestingOffice] ORDER BY [Id] DESC"></asp:SqlDataSource>
                            </td>
                        </tr>
                    </table>
                </td>
                <td style="width: 100px">
                </td>
            </tr>
            <tr height="15px" class="footer">
                <td colspan="3" style="filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr='#7A92CB', endColorStr='#D5DCEB', gradientType='1');
                    height: 15px;">
                    <uc2:footermenu ID="Footermenu1" runat="server" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

Open in new window

0
 
Vx_ChemicalAuthor Commented:
and the code behind which you asked for,

The table from the database that the original was using is called Visitors, the new one i want to look at is called Visitors2.


using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class visitoraccess_Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //Checking login status...
        string loggedInString = Session["loggedIn"].ToString();
        if (loggedInString == "0")
        {
            Response.Redirect("~/default.aspx?source=" + Request.Url.AbsolutePath.ToString() + "");
        }
        string isRsoString = Session["isRsoAdmin"].ToString();
        if (isRsoString == "0")
        {
            Response.Redirect("Default.aspx?status=noaccess");
        }
        if (!Page.IsPostBack)
        {
            dropDownFill();
            requestFill();
        }
    }
    protected void submitBtn_Click(object sender, EventArgs e)
    {
        string idTagString = Request.QueryString["Id"];
        string pageSrc = Request.QueryString["pageSrc"];
        string loggedInUser = Session["sessionUserName"].ToString();

        //stupid INT , needs to add one to day, because of old visitor program... stupid... 
        DateTime dateOfAccessTo = new DateTime();
        object dateOfAccessFrom = fromYearDropDown.SelectedValue + "/" + fromMonthDropDown.SelectedValue + "/" + fromDayDropDown.SelectedValue;
        dateOfAccessTo = System.DateTime.Parse((toYearDropDown.SelectedValue + "/" + toMonthDropDown.SelectedValue + "/" + toDayDropDown.SelectedValue).ToString());
        dateOfAccessTo = dateOfAccessTo.AddDays(1);
        string addOneDayString = dateOfAccessTo.ToShortDateString();

        //Search replacing for apostrophies... 
        otherReasonTxtBox.Text = otherReasonTxtBox.Text.Replace("'", "''");
        specialReqTxtBox.Text = specialReqTxtBox.Text.Replace("'", "''");
        escortNameTxtBox.Text = escortNameTxtBox.Text.Replace("'", "''");
        companyTxtBox.Text = companyTxtBox.Text.Replace("'", "''");
        firstNameTxtBox.Text = firstNameTxtBox.Text.Replace("'", "''");
        lastNameTxtBox.Text = lastNameTxtBox.Text.Replace("'", "''");
        requesterNameTxtBox.Text = requesterNameTxtBox.Text.Replace("'", "''");
        citizenshipTxtBox.Text = citizenshipTxtBox.Text.Replace("'", "''");
        eccTxtBox.Text = eccTxtBox.Text.Replace("'", "''");
        vehicleLicenTxtBox.Text = vehicleLicenTxtBox.Text.Replace("'", "''");

        try
        {
            SqlConnection myConnectionSetting = new SqlConnection(ConfigurationSettings.AppSettings["VisitorAccessConnectionString"]);
            myConnectionSetting.Open();
            SqlCommand myCommandWrite = new SqlCommand("UPDATE Visitors2 SET LastName = '" + lastNameTxtBox.Text + "', FirstName = '" + firstNameTxtBox.Text + "', Company = '" + companyTxtBox.Text + "', Citizenship = '" + citizenshipTxtBox.Text + "', VisitingSection = '" + visitSecDropDown.SelectedValue + "', SpecialRequire = '" + specialReqTxtBox.Text + "', Clearance = '" + clearDropDown.SelectedValue + "', eccNo = '" + eccTxtBox.Text + "', OtherReasonForAccess = '" + otherReasonTxtBox.Text + "', Location_Id = '" + locationDropDown.SelectedValue + "', TimeOfAccessFrom = '" + timeFromDropDown.SelectedValue + "', TimeOfAccessTo = '" + timeToDropDown.SelectedValue + "', DateofAccessFromD = '" + fromDayDropDown.SelectedValue + "', DateOfAccessFromM = '" + fromMonthDropDown.SelectedItem + "', DateOfAccessFromY = '" + fromYearDropDown.SelectedValue + "', DateOfAccessFrom = '" + dateOfAccessFrom + "', DateOfAccessToM = '" + toMonthDropDown.SelectedItem + "', DateOfAccessToD = '" + toDayDropDown.SelectedValue + "', DateOfAccessToY = '" + toYearDropDown.SelectedValue + "', DateOfAccessTo = '" + addOneDayString + "', VehicleLicensePlate = '" + vehicleLicenTxtBox.Text + "', VehicleType = '" + vehicleDropDown.SelectedValue + "', RequestingOffice_Id = '" + officeDropDown.SelectedValue + "', Escort = '" + escortNameTxtBox.Text + "', RequestorName = '" + requesterNameTxtBox.Text + "', Badge = '" + badgeDropDown.SelectedItem + "', RsoComment = '" + RsoCommentTxtBox.Text + "', ApprovedBy = '" + loggedInUser + "', IsApproved = '" + statusDropDown.SelectedValue + "' WHERE Id=" + idTagString + "", myConnectionSetting);
            myCommandWrite.ExecuteNonQuery();
            myConnectionSetting.Close();
        }
        catch
        {
        }
        if (pageSrc == "admin")
        {
            Response.Redirect("~/visitoraccess/administerrequests.aspx");
        }
        Response.Redirect("~/visitoraccess/pending.aspx");

    }

    protected void requestFill()
    {
        string idTagString = Request.QueryString["Id"];
        string table = "Visitors2";
        string location = "";
        string dateFromD = "";
        string dateFromM = "";
        string dateFromY = "";
        string dateToD = "";
        string dateToM = "";
        string dateToY = "";
        string requestOffice = "";
        string requestStatus = "";
        string isApproved = "";
        string badge = "";
        string country = "";
        string visitSecStr = "";

        try
        {
            SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["VisitorAccessConnectionString"]);
            myConnection.Open();
            SqlDataReader myReader = null;
            SqlCommand myCommand = new SqlCommand("SELECT * FROM [" + table + "] WHERE ([Id] = " + idTagString + ")", myConnection);

            myReader = myCommand.ExecuteReader();
            while (myReader.Read())
            {
                firstNameTxtBox.Text = myReader["FirstName"].ToString();
                lastNameTxtBox.Text = myReader["LastName"].ToString();
                companyTxtBox.Text = myReader["Company"].ToString();
                vehicleLicenTxtBox.Text = myReader["VehicleLicensePlate"].ToString();
                reasonDropDown.SelectedValue = myReader["Reason_Id"].ToString();
                otherReasonTxtBox.Text = myReader["OtherReasonForAccess"].ToString();
                fromYearDropDown.SelectedValue = myReader["DateOfAccessFromY"].ToString();
                toDayDropDown.SelectedValue = myReader["DateOfAccessToD"].ToString();
                toYearDropDown.SelectedValue = myReader["DateOfAccessToY"].ToString();
                timeFromDropDown.SelectedValue = myReader["TimeOfAccessFrom"].ToString();
                timeToDropDown.SelectedValue = myReader["TimeOfAccessTo"].ToString();
                requesterNameTxtBox.Text = myReader["RequestorName"].ToString();
                escortNameTxtBox.Text = myReader["Escort"].ToString();
                dateReceiveLabel.Text = myReader["RequestDate"].ToString();
                citizenshipTxtBox.Text = myReader["Citizenship"].ToString();
                specialReqTxtBox.Text = myReader["SpecialRequire"].ToString();

                visitSecStr = myReader["VisitingSection"].ToString();
                if (visitSecStr != "")
                {
                    visitSecDropDown.SelectedValue = visitSecStr;
                }
                locationDropDown.SelectedValue = myReader["Location_Id"].ToString();
                clearDropDown.SelectedValue = myReader["FirstName"].ToString();
                vehicleDropDown.SelectedValue = myReader["VehicleType"].ToString();
                fromDayDropDown.SelectedValue = myReader["DateofAccessFromD"].ToString();
                clearDropDown.SelectedValue = myReader["Clearance"].ToString();
                officeDropDown.SelectedValue = myReader["RequestingOffice_Id"].ToString();
                eccTxtBox.Text = myReader["eccNo"].ToString();
                badge = myReader["Badge"].ToString();
                RsoCommentTxtBox.Text = myReader["RsoComment"].ToString();

                dateFromM = myReader["DateOfAccessFromM"].ToString();
                dateFromM = monthConverter(dateFromM);
                fromMonthDropDown.SelectedValue = dateFromM;

                dateToM = myReader["DateOfAccessToM"].ToString();
                dateToM = monthConverter(dateToM);
                toMonthDropDown.SelectedValue = dateToM;

                if (badge != "")
                {
                    badgeImage.Visible = true;
                    badgeImage.ImageUrl = "~/images/" + badge + "-b.gif";
                    badgeDropDown.SelectedValue = badge;
                }
                isApproved = myReader["IsApproved"].ToString();
                if (isApproved == "True")
                {
                    statusDropDown.SelectedValue = "1";
                }
                if (isApproved == "False")
                {
                    statusDropDown.SelectedValue = "0";
                }
            }
            myReader.Close();
        }
        catch
        {
        }
    }
    protected void dropDownFill()
    {
        //Autofilling dropdownlists        
        ArrayList dayArray = new ArrayList();
        ArrayList yearArray = new ArrayList();
        dayArray.Add("");
        yearArray.Add("");
        int day = 1;
        int currentYear = DateTime.Now.Year;
        currentYear++;
        {
            while (day <= 31)
            {
                dayArray.Add(day);
                day++;
            }
            while (currentYear >= 1999)
            {
                yearArray.Add(currentYear);
                currentYear--;
            }
            fromDayDropDown.DataSource = dayArray;
            fromDayDropDown.DataBind();
            fromYearDropDown.DataSource = yearArray;
            fromYearDropDown.DataBind();
            toDayDropDown.DataSource = dayArray;
            toDayDropDown.DataBind();
            toYearDropDown.DataSource = yearArray;
            toYearDropDown.DataBind();
            toDayDropDown.SelectedValue = DateTime.Now.Day.ToString();
            toYearDropDown.SelectedValue = DateTime.Now.Year.ToString();
            toMonthDropDown.SelectedValue = DateTime.Now.Month.ToString();
            fromDayDropDown.SelectedValue = DateTime.Now.Day.ToString();
            fromYearDropDown.SelectedValue = DateTime.Now.Year.ToString();
            fromMonthDropDown.SelectedValue = DateTime.Now.Month.ToString();
        }

    }
    protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
    {
        badgeImage.Visible = true;
        badgeImage.ImageUrl = "~/images/" + badgeDropDown.Text + "-b.gif";
    }
    protected void delButton_Click(object sender, EventArgs e)
    {
        try
        {
            string idTagString = Request.QueryString["Id"];
            string pageSrc = Request.QueryString["pageSrc"];
            SqlConnection myConnectionSetting = new SqlConnection(ConfigurationSettings.AppSettings["VisitorAccessConnectionString"]);
            myConnectionSetting.Open();

            SqlCommand myCommandWrite = new SqlCommand("DELETE FROM [Visitors2] WHERE [Id] = " + idTagString + "", myConnectionSetting);
            myCommandWrite.ExecuteNonQuery();
            myConnectionSetting.Close();

            if (pageSrc == "admin")
            {
                Response.Redirect("~/visitoraccess/administerrequests.aspx");
            }
            Response.Redirect("~/visitoraccess/pending.aspx");
        }
        catch
        {
        }
    }
    protected string monthConverter(string monthStr)
    {
        int monthNo = 0;

        if (monthStr == "Jan")
        { monthNo = 1; }
        if (monthStr == "Feb")
        { monthNo = 2; }
        if (monthStr == "Mar")
        { monthNo = 3; }
        if (monthStr == "Apr")
        { monthNo = 4; }
        if (monthStr == "May")
        { monthNo = 5; }
        if (monthStr == "June")
        { monthNo = 6; }
        if (monthStr == "July")
        { monthNo = 7; }
        if (monthStr == "Aug")
        { monthNo = 8; }
        if (monthStr == "Sep")
        { monthNo = 9; }
        if (monthStr == "Oct")
        { monthNo = 10; }
        if (monthStr == "Nov")
        { monthNo = 11; }
        if (monthStr == "Dec")
        { monthNo = 12; }

        return monthNo.ToString();
    }
}

Open in new window

0
 
guru_samiCommented:
Ok so this is the command you are executing:
SqlCommand myCommand = new SqlCommand("SELECT * FROM [" + table + "] WHERE ([Id] = " + idTagString + ")", myConnection);

Can you set the breakpoint at lines 101,106,107 to see what value is assigned to your table. Also just to make sure try rebuilding the solution as sometimes the VS ignores the changes and the cached version is used.
Also if you try running the query directly in sql server ....is it returning correct results?
0
 
Vx_ChemicalAuthor Commented:
I reckon its about the hyperlinkfield and the data navigationfield, something in them that needs editing to make it work? Unfortunately I am not at work, so I don't have the code.
0
 
guru_samiCommented:
You mean this:
  <asp:HyperLinkField DataNavigateUrlFields="Id" DataNavigateUrlFormatString="approve.aspx?Id={0}"
                                DataTextField="FullName" HeaderText="Visitor Name">

It is just passing the "id" to next page...which is used by your select query...so i am not sure how that link is affecting what is being displayed....

Ok let us know your debugging observations when you get chance.
0
 
Vx_ChemicalAuthor Commented:
Thank you Guru

I unfortunately dont have the luxury to be using Visual Studio for this, since the company policy prohibits installing it on our primary system where the page is located.

What does the  ["+ table +"] mean, is that wher it gets what table to use?

There are two tables, the old, Visitor, and the new one Visitor2.

thank you again for taking time to help me.
0
 
guru_samiCommented:
--->What does the  ["+ table +"] mean, is that wher it gets what table to use?
Yes...I understand that....and also see that you are setting table="Visitors2" ...
any way did you try running your command in sql directly?
Do you have access to SqlProfiler (i.e available via Sql Server management Studio)?
If yes....try to use that to see what query is actually executed when you go to next page.

Note: You can try using Response.Write(table); if you cannot use VS to set breakpoints and debug.
0
All Courses

From novice to tech pro — start learning today.