您好伙伴我有一个页面查看所有Applicants.aspx with gridview和一个链接按钮
我想重定向到页面查看申请人Detail.aspx,当我点击链接按钮,我想在View Applicant Detail.aspx页面上的gridview中显示基于前一页面值的数据。
这是View All Applicants.aspx的代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="View All Applicants.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div><center>
</center>
<center style="background-color: silver">
</center>
<center>
<strong><span style="font-size: 16pt">List of All Applicants</span></strong></center>
<center style="background-color: silver">
</center>
<center>
</center>
<center>
</center>
<center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" AllowPaging="True"
>
<Columns>
<asp:BoundField DataField="PersonName" HeaderText="PersonName" SortExpression="PersonName" />
<asp:BoundField DataField="DegreeName" HeaderText="DegreeName" SortExpression="DegreeName" />
<asp:BoundField DataField="InstituteName" HeaderText="InstituteName" SortExpression="InstituteName" />
<asp:BoundField DataField="ExperienceYears" HeaderText="ExperienceYears" SortExpression="ExperienceYears" />
<asp:BoundField DataField="OrganizationName" HeaderText="OrganizationName" SortExpression="OrganizationName" />
<asp:BoundField DataField="Designation" HeaderText="Designation" SortExpression="Designation" />
<asp:TemplateField HeaderText="Applicant Detail">
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Cancel"
OnClick="LinkButton1_Click" Text="View"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString8 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString8.ProviderName %>" SelectCommand="SELECT Distinct PERSONALDETAIL.PersonName, DEGREE.DegreeName, INSTITUTE.InstituteName, EXPERIENCE.ExperienceYears, EXPERIENCE.OrganizationName, EXPERIENCE.Designation FROM EXPERIENCE, EXPERIENCE EXPERIENCE_1, PERSONALDETAIL, DEGREE, INSTITUTE WHERE EXPERIENCE.ExperienceID = EXPERIENCE_1.ExperienceID">
</asp:SqlDataSource>
</center>
<center>
</center>
<center>
</center>
<center style="background-color: silver">
</center>
</div>
</form>
</body>
</html>
和View Applicant Detail.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="View Applicant Detail.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div><center>
</center>
<center style="background-color: silver">
</center>
<center>
<strong><span style="font-size: 16pt">Job Applicant Detail</span></strong></center>
<center style="background-color: silver">
</center>
<center>
</center>
<center>
</center>
<center>
</center>
<center>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ResumeID"
DataSourceID="SqlDataSource1">
<Columns>
<asp:BoundField DataField="ResumeID" HeaderText="ResumeID" InsertVisible="False"
ReadOnly="True" SortExpression="ResumeID" />
<asp:BoundField DataField="TotalExperienceYears" HeaderText="TotalExperienceYears"
SortExpression="TotalExperienceYears" />
<asp:BoundField DataField="TotalExperienceMonths" HeaderText="TotalExperienceMonths"
SortExpression="TotalExperienceMonths" />
<asp:BoundField DataField="ExperienceSummary" HeaderText="ExperienceSummary" SortExpression="ExperienceSummary" />
<asp:BoundField DataField="DetailedCVName" HeaderText="DetailedCVName" SortExpression="DetailedCVName" />
<asp:BoundField DataField="AdditionalQualification" HeaderText="AdditionalQualification"
SortExpression="AdditionalQualification" />
<asp:BoundField DataField="ExtraCurricular" HeaderText="ExtraCurricular" SortExpression="ExtraCurricular" />
<asp:BoundField DataField="Skills" HeaderText="Skills" SortExpression="Skills" />
<asp:BoundField DataField="TentativeFromDate" HeaderText="TentativeFromDate" SortExpression="TentativeFromDate" />
<asp:BoundField DataField="PageIndex" HeaderText="PageIndex" SortExpression="PageIndex" />
<asp:BoundField DataField="PersonalDetailID" HeaderText="PersonalDetailID" SortExpression="PersonalDetailID" />
<asp:BoundField DataField="DepartmentID" HeaderText="DepartmentID" SortExpression="DepartmentID" />
<asp:BoundField DataField="DesignationID" HeaderText="DesignationID" SortExpression="DesignationID" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString5 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString5.ProviderName %>" SelectCommand="SELECT * FROM [RESUME]">
</asp:SqlDataSource>
</center>
<center>
</center>
<center>
</center>
<center>
</center>
<center style="background-color: silver">
</center>
</div>
</form>
</body>
</html>
答案 0 :(得分:0)
您不必执行postbask将用户重定向到详细信息页面,您可以编辑模板列以直接转到详细信息页面的URL以及查找所需ID的GET变量。
<asp:TemplateField HeaderText="Applicant Detail">
<ItemTemplate>
<asp:HyperLink NavigateUrl="DetailsView.aspx?ResumeID=" + "<%# Bind("ResumeID") %>" Text="Visit W3Schools!" Target="_blank" runat="server" />
</ItemTemplate>
</asp:TemplateField>
在“详细信息”页面中,执行Request.QueryString(“ResumeID”)以获取进行查找所需的ID。