Hi,
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.Data.SqlClient;
using System.Web.Configuration;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Data.OleDb;
using System.Net;
using System.Net.Mail;
using System.Web.Services;
public partial class jobListing : System.Web.UI.Page
{
DateTime now = DateTime.Now;
SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
protected void Page_Load(object sender, EventArgs e)
{
//string applicantID = Session["ap_id"].ToString();
//lblMsg.Text = "Date today:" +now ;
loadJobList();
}
// Display record from tbl_company
protected void loadJobList()
{
con.Open();
SqlCommand cmd = new SqlCommand("SELECT j.j_id, j.j_position, j.j_location, j.j_category, j.j_datepublished, j.j_dateend, j.j_requirement, j.j_keyobjective, j.j_responsibilities, c.c_name, f.f_description FROM tbl_jobdescription j , tbl_company c , tbl_functionalarea f WHERE j.c_id = c.c_id AND j.f_id = f.f_id", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
int count = ds.Tables[0].Rows.Count;
con.Close();
if (ds.Tables[0].Rows.Count > 0)
{
GridViewJL.DataSource = ds;
GridViewJL.DataBind();
}
else
{
ds.Tables[0].Rows.Add(ds.Tables[0].NewRow());
GridViewJL.DataSource = ds;
GridViewJL.DataBind();
int columncount = GridViewJL.Rows[0].Cells.Count;
//lblmsg.Text = " No data found !!!";
}
}
//Paging Function
protected void PagingJL(object sender, GridViewPageEventArgs e)
{
GridViewJL.PageIndex = e.NewPageIndex;
loadJobList();
}
//Job Posting Link
protected void GridViewJL_OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string position = ((Label)e.Row.FindControl("lblposting")).Text;
string jid = ((Label)e.Row.FindControl("lbljobID")).Text;
e.Row.Cells[2].Text = position;
HyperLink h = new HyperLink();
h.Text = e.Row.Cells[2].Text;
h.NavigateUrl = "jobDescription.aspx?j_id=" + jid;
e.Row.Cells[2].Controls.Add(h);
}
}
}
Where should I put the code below? :
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
DateTime publishedDate = Convert.ToDateTime(e.Row.Cells[4].Text);
DateTime endDate = Convert.ToDateTime(e.Row.Cells[5].Text);
if (endDate <= Convert.ToDateTime(DateTime.Now.ToShortDateString()))
{
e.Row.Visible = false;
}
}
}
I already tried but its not working