using System;
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;
public partial class ShowData : System.Web.UI.Page
{
Connection con = new Connection();
DataTable dtable;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fillgrid();
Session.Add("ope", "Listing");
}
}
protected void fillgrid()
{
string query = "select * from test_reg";
dtable = con.sqlSelect(query);
grdList.DataSource = dtable;
grdList.DataBind();
}
public string getImage(string Photo)
{
string varimg = "~/Image/";
varimg += Photo;
return varimg;
}
protected void grdList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdList.PageIndex = e.NewPageIndex;
fillgrid();
}
protected void grdList_Sorting(object sender, GridViewSortEventArgs e)
{
string query = "select * from test_reg";
dtable = con.sqlSelect(query);
Session["sort"] = e.SortExpression;
string sortstr = Session["sort"].ToString();
DataView dview = new DataView(dtable);
if (sortstr == "asc")
dview.Sort = e.SortExpression + " desc";
else
dview.Sort = e.SortExpression + " asc";
grdList.DataSource = dview;
grdList.DataBind();
}
protected void grdList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int uid = Convert.ToInt32(grdList.DataKeys[e.RowIndex].Values[0]);
con.sql_delete_data(uid);
fillgrid();
}
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
Session.Add("ope", "Listing");
if (TextBox1.Text != "")
{
string query = "select * from test_reg where Id=" + TextBox1.Text;
dtable = con.sqlSelect(query);
grdList.DataSource = dtable;
grdList.DataBind();
TextBox1.Text = "";
}
else
{
string query = "select * from test_reg";
dtable = con.sqlSelect(query);
grdList.DataSource = dtable;
grdList.DataBind();
}
}
protected void grdList_RowEditing(object sender, GridViewEditEventArgs e)
{
int test_reg_Id = Convert.ToInt32(grdList.DataKeys[e.NewEditIndex].Values[0]);
Session.Add("ope", "Edit");
Session.Add("test_reg_Id", test_reg_Id);
Response.Redirect("newuser.aspx");
}
protected void logout_Click(object sender, EventArgs e)
{
Response.Write("<script language=javascript> window.open('Login.aspx','_parent',replace=false);
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;
public partial class ShowData : System.Web.UI.Page
{
Connection con = new Connection();
DataTable dtable;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
fillgrid();
Session.Add("ope", "Listing");
}
}
protected void fillgrid()
{
string query = "select * from test_reg";
dtable = con.sqlSelect(query);
grdList.DataSource = dtable;
grdList.DataBind();
}
public string getImage(string Photo)
{
string varimg = "~/Image/";
varimg += Photo;
return varimg;
}
protected void grdList_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdList.PageIndex = e.NewPageIndex;
fillgrid();
}
protected void grdList_Sorting(object sender, GridViewSortEventArgs e)
{
string query = "select * from test_reg";
dtable = con.sqlSelect(query);
Session["sort"] = e.SortExpression;
string sortstr = Session["sort"].ToString();
DataView dview = new DataView(dtable);
if (sortstr == "asc")
dview.Sort = e.SortExpression + " desc";
else
dview.Sort = e.SortExpression + " asc";
grdList.DataSource = dview;
grdList.DataBind();
}
protected void grdList_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int uid = Convert.ToInt32(grdList.DataKeys[e.RowIndex].Values[0]);
con.sql_delete_data(uid);
fillgrid();
}
protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
{
Session.Add("ope", "Listing");
if (TextBox1.Text != "")
{
string query = "select * from test_reg where Id=" + TextBox1.Text;
dtable = con.sqlSelect(query);
grdList.DataSource = dtable;
grdList.DataBind();
TextBox1.Text = "";
}
else
{
string query = "select * from test_reg";
dtable = con.sqlSelect(query);
grdList.DataSource = dtable;
grdList.DataBind();
}
}
protected void grdList_RowEditing(object sender, GridViewEditEventArgs e)
{
int test_reg_Id = Convert.ToInt32(grdList.DataKeys[e.NewEditIndex].Values[0]);
Session.Add("ope", "Edit");
Session.Add("test_reg_Id", test_reg_Id);
Response.Redirect("newuser.aspx");
}
protected void logout_Click(object sender, EventArgs e)
{
Response.Write("<script language=javascript> window.open('Login.aspx','_parent',replace=false);
</script>");
Session["name"] = null;
}
}
Session["name"] = null;
}
}
No comments:
Post a Comment