Hi friends,
How to find in grid , deleted records, updated records just i want know this count to show before
update in database. how to filter.
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Satyapriya NayakPosted Nov 19, 2011, 11:59 AM
Try this...
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.Collections.Specialized;
using System.Collections.Generic;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlCommand cmd = new SqlCommand();
SqlConnection con;
string str;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
BindGridView();
totalrecords();
}
private void totalrecords()
{
con = new SqlConnection(connStr);
con.Open();
str = "select count(*) from employee ";
SqlCommand cmd = new SqlCommand(str, con);
int row = (int)cmd.ExecuteScalar();
Label2.Text = row.ToString();
con.Close();
}
private void BindGridView()
{
con = new SqlConnection(connStr);
cmd.Connection = con;
cmd.CommandText = "Select * from employee";
con.Open();
GridView1.DataSource = cmd.ExecuteReader();
GridView1.DataBind();
con.Close();
}
protected void ButtonDelete_Click(object sender, EventArgs e)
{
// Your code for delete
BindGridView();
totalrecords();
}
Thanks