Programming in almost language

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

Archive for February 11th, 2008

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;
}
}

Posted in DATAGRID AND GRIDVIEW | Tagged: | Leave a Comment »

Write XML file through C#

Posted by Praveen Kumar on February 11, 2008

try {
var pageTracker = _gat._getTracker(“UA-7968286-1″);
pageTracker._trackPageview();
} catch(err) {}
protected void Button1_Click(object sender, EventArgs e)
{

try {
//XmlDataDocument sourceXML = new XmlDataDocument();
string xmlFile = Server.MapPath(“DVDlist.xml”);
//create a XML file is not exist
System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(xmlFile, null);
//starts a new document
writer.WriteStartDocument();
//write comments
writer.WriteComment(“Commentss: XmlWriter Test Program”);
writer.Formatting = Formatting.Indented;

writer.WriteStartElement(“DVDlist”);
writer.WriteStartElement(“DVD”);
writer.WriteAttributeString(“ID”, “1″);

//write some simple elements
writer.WriteElementString(“Title”, “Tere Naam”);
writer.WriteStartElement(“Starring”);
writer.WriteElementString(“Actor”, “Salman Khan”);
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();

writer.Close();
} catch (Exception e1) { Page.Response.Write(e1); }
}

Posted in XML | Tagged: | 66 Comments »