Dear Sir,
I want to add department wise filter in gridview header.
namespace TS
{
public partial class Dashboard : System.Web.UI.Page
{
string strConnString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
string str;
SqlCommand com;
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.BindGridView();
}
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString))
{
using (SqlCommand cmd = new SqlCommand("SELECT MAX(updated_on) FROM ts2", con))
{
con.Open();
Label1.Text = Convert.ToString(cmd.ExecuteScalar());
con.Close();
}
}
}
private void BindGridView()
{
string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("select * from ts2 ORDER BY Id DESC "))
{
using (SqlDataAdapter sda = new SqlDataAdapter())
{
cmd.Connection = con;
sda.SelectCommand = cmd;
using (DataTable dt = new DataTable())
{
sda.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
}
}
}
}
}