Wednesday, October 22, 2008

Remove a HTML Element using Javascript

3 comments
Suppose the ID of the element is "objID"

The JavaScript method.(We are writing a custom function)



function removeElement(objID) {
var node = document.getElementById(objID);
node.parentNode.removeChild(node);
}



The JQuery method.



$("#objID").remove();



Its all about Keeping it Simple.
What do you say? :)
Read more...

Thursday, October 16, 2008

Copy DataRows from one DataTable to Another

0 comments
"This row already belongs to another table" - Annoying, to say the least!

The workaround, simple but elusive.



public DataTable CopyDataTable(DataTable dtSource, int iRowsNeeded)
{

if (dtSource.Rows.Count > iRowsNeeded)
{
// cloned to get the structure of source
DataTable dtDestination = dtSource.Clone();
for (int i = 0; i < iRowsNeeded; i++)
{
dtDestination.ImportRow(dtSource.Rows[i]);
}
return dtDestination;
}
else
return dtSource;
}



Happy Coding!
Read more...