У меня есть страница со списком всех вакансий. Мне нужно запрограммировать кнопку так, чтобы при нажатии на нее я направлял меня к указанной c информации о вакансии. Как мне это сделать. Я пробовал navigateUrl, но когда я нажимаю на кнопку, ничего не происходит.
Вот мой код для моего шаблона элемента
<asp:ListView ID="lsvJob" runat="server">
<ItemTemplate>
<div class="nf-item branding coffee spacing">
<div class="col-md-6 col-lg-4 mb-30">
<div class="service_box">
<figure>
<asp:Image ID="imgposter" ImageUrl='<%# Eval("HO_Image", "~/Images/{0}") %>'
runat="server" Height="300px" Width="300px" ImageAlign="Top" />
</figure>
<h3><%#Eval("Job_Name") %></h3>
<p>
<b>Employer Name:</b> <%# Eval("HO_LastName") %> <%# Eval("HO_FirstName") %>
<br />
<b>Email Address:</b> <%# Eval("HO_Email") %>
</p>
<asp:LinkButton ID="lnkmovdetails" runat="server" Text="View Details"
NavigateUrl='<%# Eval("Job_ID","~/jobdetails.aspx?id={0}")%>' CommandName="btnAccess" CssClass="btn btn-info"></asp:LinkButton>
</div>
</div>
</div>
</ItemTemplate>
</asp:ListView>
код позади
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Web.Configuration;
using System.Data.SqlClient;
namespace moCoolMaid
{
public partial class listjob : System.Web.UI.Page
{
private string _conString =
WebConfigurationManager.ConnectionStrings["MaidCS"].ConnectionString;
protected void Page_Load(object sender, EventArgs e)
{
// Create Connection
using (SqlConnection con = new SqlConnection(_conString))
{
// Create Command
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText = " SELECT tblHO.*, tblJob.* FROM tblHO, tblJob WHERE tblJob.HO_ID=tblHO.HO_ID";
//Create DataReader
SqlDataReader reader;
con.Open();
reader = cmd.ExecuteReader();
//Bind the reader to the repeater control
lsvJob.DataSource = reader;
lsvJob.DataBind();
con.Close();
}
}
}
}
Код в моей подробной веб-форме
<asp:DetailsView ID="dsvJob" runat="server" AutoGenerateRows="False" DataSourceID="SqlDataSource1" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="10" GridLines="Vertical">
<AlternatingRowStyle BackColor="Gainsboro" />
<EditRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<Fields>
<asp:BoundField DataField="Job_Name" HeaderText="Job_Name" SortExpression="Job_Name" />
<asp:BoundField DataField="Job_Desc" HeaderText="Job_Desc" SortExpression="Job_Desc" />
<asp:BoundField DataField="Job_Salary" HeaderText="Job_Salary" SortExpression="Job_Salary" ItemStyle-HorizontalAlign="Left" />
<asp:BoundField DataField="Deadline_Date" HeaderText="Deadline_Date" SortExpression="Deadline_Date" />
<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
<asp:BoundField DataField="Min_Experience" HeaderText="Min_Experience" SortExpression="Min_Experience" />
<asp:BoundField DataField="Min_Qualification" HeaderText="Min_Qualification" SortExpression="Min_Qualification" />
</Fields>
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MaidCS %>" SelectCommand="SELECT [Job_Name], [Job_Desc], [Job_Salary], [Deadline_Date], [Type], [Min_Experience], [Min_Qualification] FROM [tblJob]"></asp:SqlDataSource>