Display Login history according to System date.
===============================================
Hi FRNDS !!
I have Login history of the User, UserLogin details and UserLogout Details.
In GRIDVIEW it shows all the Records. but the REcords are not displaying correctly.
I need the last Few minutes login in the First row and todays users login history in the first page of GRIDVIEW.
Note : according to Date Wise it should display in GRIDVIEW.
This is my code :
==================
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Web.Configuration;
public partial class Users_UserLoginHistory : System.Web.UI.Page
{
string conString = ConfigurationManager.ConnectionStrings["KKIA_RUHConnectionString"].ToString();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridData();
}
}
protected void BtnSearch_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand("Select LogId,UserName,Login_Time,Logout_Time from UserLogs where UserName='" + TxtSearch.Text + "' order by Login_Time desc", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
Grid1.DataSource = dt;
Grid1.DataBind();
}
private void GridData()
{
SqlConnection con = new SqlConnection(conString);
SqlCommand cmd = new SqlCommand("Select LogId,UserName,Login_Time,Logout_Time from UserLogs order by Login_Time desc", con);
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
Grid1.DataSource = dt;
Grid1.DataBind();
}
}
Please help me,
Thanks.