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;
public partial class Online_and_offline : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=AAPTI-E86BE99D7\SQLEXPRESS;Initial Catalog=offline;Integrated Security=True");
SqlCommand cmd = new SqlCommand();
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Status_ActiveTabChanged(Status,null);
}
}
protected void Status_ActiveTabChanged(object sender, EventArgs e)
{
con.Open();
try
{
if (Status.ActiveTabIndex == 0)
{
SqlDataAdapter ad = new SqlDataAdapter("select Name,Status from Total where Status='online'", con);
ad.Fill(ds);
if (ds!=null)
{
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Visible = true;
}
con.Close();
}
if (Status.ActiveTabIndex == 1)
{
SqlDataAdapter ad1 = new SqlDataAdapter("select Name,Status from Total where Status='offline'", con);
ad1.Fill(ds);
if (ds != null)
{
GridView2.DataSource = ds;
GridView2.DataBind();
GridView2.Visible = true;
}
con.Close();
}
if (Status.ActiveTabIndex == 2)
{
SqlDataAdapter ad2 = new SqlDataAdapter("Select * from Total", con);
ad2.Fill(ds);
if (ds != null)
{
GridView3.DataSource = ds;
GridView3.DataBind();
GridView3.Visible = true;
}
con.Close();
}
}
catch (Exception ex)
{
Response.Write("<script>alert('Failed')</script>");
}
}
}
No comments:
Post a Comment