private void SetInitialRow()
{
DataTable dt = new DataTable();
DataRow dr = null;
dt.Columns.Add(new DataColumn("RowNumber", typeof(string)));
dt.Columns.Add(new DataColumn("Column1", typeof(string)));
dt.Columns.Add(new DataColumn("Column2", typeof(string)));
dt.Columns.Add(new DataColumn("Column3", typeof(string)));
dr = dt.NewRow();
dr["RowNumber"] = 1;
dr["Column1"] = string.Empty;
dr["Column2"] = string.Empty;
dr["Column3"] = string.Empty;
dt.Rows.Add(dr);
//Store the DataTable in ViewState
ViewState["CurrentTable"] = dt;
Gridview1.DataSource = dt;
Gridview1.DataBind();
}
Dynamic DataTable in ASP.NET
Serialization ~ Short Description
Serialization is a process by which we can save the state of the object by converting the object in to stream of bytes.These bytes can then be stored in database, files, memory etc.
Below is a simple code of serializing the object.
MyObject objObject = new MyObject();
objObject.Value = 100;
// Serialization using SoapFormatter
SoapFormatter formatter = new SoapFormatter();
Stream objFileStream = new FileStream("c:\\MyFile.xml", FileMode.Create, FileAccess.Write, FileShare.None);
formatter.Serialize(objFileStream, objObject);
objFileStream.Close();
Below is simple code which shows how to deserialize an object.
//De-Serialization
Stream objNewFileStream = new FileStream("c:\\MyFile.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
MyObject objObject =(MyObject)formatter.Deserialize(objNewFileStream);
objNewFileStream.Close();
Stream objNewFileStream = new FileStream("c:\\MyFile.xml", FileMode.Open, FileAccess.Read, FileShare.Read);
MyObject objObject =(MyObject)formatter.Deserialize(objNewFileStream);
objNewFileStream.Close();
Get All checked-Checkbox whose ID ~ start with "email_"
get all checked CheckBox whose id start with "email_"
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script>
$(document).ready(function () {
$("button").click(function () {
$('input[id^="email_"]:checked').each(function () {
alert($(this).attr('id'));
});
alert($(this).attr('id'));
});
});
});
</script>
----- This should be in header portion of a page And As you see this is done by the Jquery :)
Simple AJAX Application ~ Codding
Posted by
Abhirup Sinha Roy
at
8:33 PM
<script>
var xmlhttp;
function loadXMLDoc(url,cfunc)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=cfunc;
xmlhttp.open("GET",url,true);
xmlhttp.send();
}
function myFunction()
{
loadXMLDoc("ajax_info.txt",function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
});
}
</script>
---- myDiv is div id under the page.
Subscribe to:
Comments (Atom)
Search This Blog
Tags
Popular Posts
-
Some time when you bind gridview ,you can find some duplicate rows in that grid, by this underlying piece of code you can easily avoid (or...
-
#region " Declare All " DataTable dtPrint = new DataTable(); // Create Table object ...
-
http://www.refulz.com:8082/index.php#tab2?foo=789 Property Result ------------------------------------------- host www.refulz...
