Programming in almost language

This is the site where you may share your knowledge and experience to eachother..

  • Categories

  • LinkedIn

  • Tweet Me

  • My footsteps

GridView to GridView

Posted by Praveen Kumar on February 11, 2008

//// code by lakshmi vallapureddy (Anu)

protected void btnCut_Click(object sender, EventArgs e)
{
Session[“BACKUP”] = null;
DataSet ds = (DataSet)Session[“DataSet”]; Object[][] obj1 = new object[ds.Tables[0].Rows.Count][]; int backuprows = 0; for (int i = 0; i < GridView1.Rows.Count; i++){
CheckBox chk1 = (CheckBox)GridView1.Rows[i].FindControl(“ChkBox1”); if (chk1.Checked)
{ obj1[backuprows] = ds.Tables[0].Rows[i].ItemArray;
backuprows += backuprows;
ds.Tables[0].Rows.RemoveAt(i);
}}
Session[“BACKUP”] = obj1; //Store in session //Re-Bind data
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
Session[“DataSet”] = ds;
}
protected void btnPaste_Click(object sender, EventArgs e)
{
Object[][] obj1 = null; if (Session[“BACKUP”] != null)
obj1 = (
Object[][])Session[“BACKUP”]; if (obj1 != null)
{
DataSet ds = (DataSet)Session[“DataSet”]; for (int ii = 0; ii < obj1.Length; ii++)
{
//Paste if (obj1[ii] != null)
ds.Tables[0].Rows.Add(obj1[ii]);
else break;
}
GridView1.DataSource = ds.Tables[0].DefaultView;
GridView1.DataBind();
Session[“DataSet”] = ds;
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: