点击任何链接或按钮重定向到另一个页面asp.net

时间:2017-02-28 13:55:29

标签: c# asp.net gridview

我有一个asp.net网络应用程序项目,其中包括总共三个页面,即登录页面,首页和网格视图页面。当我运行应用程序时,它正常工作,但是当我点击任何链接或任何按钮时,它会指向第一页。我为gird View创建了甚至是新页面,但问题仍然存在。我不知道问题出在网格视图或数据库中。请帮助我解决这个问题,因为我在这个项目上做了很多工作。

以下是一次又一次重定向的第一页的代码

<asp:Content ID="FormContentHolder" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="container">

        <div class="row">
            <div id="logobar">
                <h1>
                    <img src="http://localhost:50090/uploads/icons/logo.png" style="height: 99px" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Document Expiry Alert System</h1>
            </div>
        </div>
        <div class="row">
            <div>
                <hr />
            </div>
            <div id="container-fluid">
                <div class="col-md-3">
                    <div id="icons">
                        <div>
                            <a href="DatabaseGView.aspx">
                                <img class="img-responsive" src="uploads/icons/update.png" /></a>
                            <a href="DatabaseGView.aspx">Update</a>
                        </div>
                    </div>
                </div>
                <div class="col-md-9">
                    <div class="form-group">
                        <div class="text-left">
                            <h1>Students Database</h1>
                        </div>
                        <table class="">
                            <tr>
                                <td class="" style="width: 30%">Registration No.</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="ID" runat="server" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="" style="width: 30%">First Name</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="FN" runat="server" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Last Name</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="LN" runat="server" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Nationality</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:DropDownList ID="Country1" runat="server" CssClass="form-control box-margin-8" Width="190px">
/--Here was very long list of countries so i removed--/
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Email</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="email" runat="server" CssClass="form-control box-margin-8" TextMode="Email" Width="190px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Passport No</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="passportNo" runat="server" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Place of Issue</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:DropDownList ID="PlaceOfIssue" runat="server" CssClass="form-control box-margin-8" Width="190px">
                                        <asp:ListItem Value="AF">Afghanistan</asp:ListItem>
/--Here was very long list of countries so i removed--/
                                    </asp:DropDownList>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Issue</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="issue" runat="server" TextMode="Date" Width="190px" CssClass="form-control box-margin-8"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Expiry</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="Expiry" runat="server" Width="190px" TextMode="Date" CssClass="form-control box-margin-8"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Visa No</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="VisaNo" CssClass="form-control box-margin-8" runat="server" Width="190px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Visa Expiry</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="VisaExpiry" runat="server" Width="190px" TextMode="Date" CssClass="form-control box-margin-8"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">Emirates ID No</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="EmiratesNo" CssClass="form-control box-margin-8" runat="server" Width="190px"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">ID Expiry</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:TextBox ID="EmiaratesExpiry" runat="server" Width="190px" TextMode="Date" CssClass="form-control box-margin-8"></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="">&nbsp;</td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">&nbsp;</td>
                            </tr>
                            <tr>
                                <td class="">&nbsp; </td>
                                <td class="" style="text-align: inherit; font-family: 'Arial Black'; overflow: auto; width: 190px;">
                                    <asp:Button ID="submitt" runat="server" class="btn" OnClick="submitt_Click" Text="Submit" />
                                    <input id="Reset1" type="button" value="reset" class="btn" onclick="myFunction()" />
                                    <asp:Label ID="Label1" runat="server" />
                                    <asp:Label ID="Label2" runat="server" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</asp:Content>

这是第二页: -

<%@ Page Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="DatabaseGView.aspx.cs" Inherits="Document_Expiry_Reminder.DatabaseGView" %>

<asp:Content ID="FormContentHolder" ContentPlaceHolderID="ContentPlaceHolder1" runat="server" >
    <link href="css/bootstrap.css" rel="stylesheet" />
    <div class="container">
        <div class="img-responsive" style="background-color: none;">
            <h1>
                <img src="http://localhost:50090/uploads/icons/logo.png" style="height: 99px" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Student Database Administration</h1>
                    </div>
                <div class="row">
            <div>
                <hr />
            </div>
        </div>
        <div class="displayflex">
            <div class="row">
                <div class="col-md-1">
                    <a href="FrontPage.aspx">
                        <img class="img-responsive" src="uploads/icons/add.png" /></a>
                    <a href="FrontPage.aspx">Add</a>
                </div>
            </div>
        </div>
    </div>
    <div class="row" style="margin-left: 5px">
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        <asp:Button ID="Button1" runat="server" Text="Search" OnClick="Button1_Click" />&nbsp;<asp:DropDownList ID="DropDownList1" runat="server">
            <asp:ListItem>Select Document</asp:ListItem>
            <asp:ListItem>Passport Expiry</asp:ListItem>
            <asp:ListItem>Visa &amp; Emirates Expiry</asp:ListItem>
        </asp:DropDownList>
        &nbsp;From Date
            <asp:TextBox ID="fromDate" runat="server" TextMode="Date"></asp:TextBox>
        &nbsp; To Date&nbsp;
            <asp:TextBox ID="toDate" runat="server" TextMode="Date"></asp:TextBox>
        &nbsp;
            <asp:Button ID="Search" runat="server" OnClick="Search_Click" Text="Search" />
        <br />
        <br />
        <asp:GridView  ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" DataKeyNames="ID" DataSourceID="SqlDataSource1"  OnRowEditing="GridView1_RowEditing" BackColor="White" BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px">
            <Columns>
                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                <asp:BoundField DataField="ID" HeaderText="Reg No" ReadOnly="True" SortExpression="ID" />
                <asp:BoundField DataField="FN" HeaderText="First" SortExpression="FN" />
                <asp:BoundField DataField="LN" HeaderText="Last" SortExpression="LN" />
                <asp:BoundField DataField="Country1" HeaderText="Country" SortExpression="Country1" />
                <asp:BoundField DataField="gender" HeaderText="Gender" SortExpression="gender" />
                <asp:BoundField DataField="email" HeaderText="Email" SortExpression="email" />
                <asp:BoundField DataField="PassportNo" HeaderText="Passport" SortExpression="PassportNo" />
                <asp:BoundField DataField="PlaceOfIssue" HeaderText="Place Of Issue" SortExpression="PlaceOfIssue" />
                <asp:BoundField DataField="Issue" HeaderText="Issue" SortExpression="Issue" DataFormatString="{0:MM/dd/yyyy}" />
                <asp:BoundField DataField="Expiry" HeaderText="Expiry" SortExpression="Expiry" DataFormatString="{0:MM/dd/yyyy}" />
                <asp:BoundField DataField="VisaNo" HeaderText="Visa" SortExpression="VisaNo" />
                <asp:BoundField DataField="VisaExpiry" HeaderText="Visa Expiry" SortExpression="VisaExpiry" DataFormatString="{0:MM/dd/yyyy}" />
                <asp:BoundField DataField="EmiratesNo" HeaderText="Emirates ID" SortExpression="EmiratesNo" />
                <asp:BoundField DataField="EmiratesExpiry" HeaderText="ID Expiry" SortExpression="EmiratesExpiry" DataFormatString="{0:MM/dd/yyyy}" />
            </Columns>
            <EditRowStyle BackColor="Black" ForeColor="#0033CC" />
            <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
            <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" BorderStyle="Groove" />
            <PagerStyle CssClass="pagination-ys" BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
            <RowStyle BackColor="White" ForeColor="#003399" HorizontalAlign="Center" />
            <SelectedRowStyle BackColor="#99CCFF" Font-Bold="True" ForeColor="#CCFF99" />
            <SortedAscendingCellStyle BackColor="#EDF6F6" />
            <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
            <SortedDescendingCellStyle BackColor="#D6DFDF" />
            <SortedDescendingHeaderStyle BackColor="#002876" />
        </asp:GridView>
        <br />
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SzabistStudentsConnectionString3 %>" DeleteCommand="DELETE FROM [Students] WHERE [ID] = @original_ID" InsertCommand="INSERT INTO [Students] ([ID], [FN], [LN], [Country1], [gender], [email], [PassportNo], [PlaceOfIssue], [Issue], [Expiry], [VisaNo], [VisaExpiry], [EmiratesNo], [EmiratesExpiry]) VALUES (@ID, @FN, @LN, @Country1, @gender, @email, @PassportNo, @PlaceOfIssue, @Issue, @Expiry, @VisaNo, @VisaExpiry, @EmiratesNo, @EmiratesExpiry)" SelectCommand="SELECT * FROM [Students]" UpdateCommand="UPDATE [Students] SET [FN] = @FN, [LN] = @LN, [Country1] = @Country1, [gender] = @gender, [email] = @email, [PassportNo] = @PassportNo, [PlaceOfIssue] = @PlaceOfIssue, [Issue] = @Issue, [Expiry] = @Expiry, [VisaNo] = @VisaNo, [VisaExpiry] = @VisaExpiry, [EmiratesNo] = @EmiratesNo, [EmiratesExpiry] = @EmiratesExpiry WHERE [ID] = @original_ID" OldValuesParameterFormatString="original_{0}">
            <DeleteParameters>
                <asp:Parameter Name="original_ID" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="ID" Type="String" />
                <asp:Parameter Name="FN" Type="String" />
                <asp:Parameter Name="LN" Type="String" />
                <asp:Parameter Name="Country1" Type="String" />
                <asp:Parameter Name="gender" Type="String" />
                <asp:Parameter Name="email" Type="String" />
                <asp:Parameter Name="PassportNo" Type="String" />
                <asp:Parameter Name="PlaceOfIssue" Type="String" />
                <asp:Parameter DbType="Date" Name="Issue" />
                <asp:Parameter DbType="Date" Name="Expiry" />
                <asp:Parameter Name="VisaNo" Type="String" />
                <asp:Parameter DbType="Date" Name="VisaExpiry" />
                <asp:Parameter Name="EmiratesNo" Type="String" />
                <asp:Parameter DbType="Date" Name="EmiratesExpiry" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="FN" Type="String" />
                <asp:Parameter Name="LN" Type="String" />
                <asp:Parameter Name="Country1" Type="String" />
                <asp:Parameter Name="gender" Type="String" />
                <asp:Parameter Name="email" Type="String" />
                <asp:Parameter Name="PassportNo" Type="String" />
                <asp:Parameter Name="PlaceOfIssue" Type="String" />
                <asp:Parameter DbType="Date" Name="Issue" />
                <asp:Parameter DbType="Date" Name="Expiry" />
                <asp:Parameter Name="VisaNo" Type="String" />
                <asp:Parameter DbType="Date" Name="VisaExpiry" />
                <asp:Parameter Name="EmiratesNo" Type="String" />
                <asp:Parameter DbType="Date" Name="EmiratesExpiry" />
                <asp:Parameter Name="original_ID" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
</asp:Content>

从第二页开始,任何点击链接或按钮都会重定向到fronpage.aspx,这是我项目中的第一页

1 个答案:

答案 0 :(得分:0)

检查母版页中的表单标签,可能已将操作设置为frontpage.aspx