In the code you can checking All CheckBoxes in a GridView follwing is the image of interface .
Using the Client Side Javascript checking the header checkbox would check all checkboxes in the GridView and after unchecking the
header checkbox would uncheck all checkboxes in the GridView .
Copy the following javascript code and put it inside the head tag .
Javascript Code for ASP.Net GridView Check All Checkbox
<script type="text/javascript">
function chkAllCheckbox(obj) {
var gv = document.getElementById('<%=GVMain.ClientID %>');
for (var i = 0; i < gv.all.length; i++) {
var node = gv.all[i];
node.checked = obj.checked;
}
}
</script>
Introduction : This article describe you how add nested gridview in asp.net . Many times we require to add nested gridview .
Nested Gridview Code : I have written the html code and code behind code for binding the nested gridview .which is shown below .It is very easy to implement nested gridview in your application just you need to add it and change the connection string and query as per you requirement .
I have added the toggle for nested gridview too.its toggle using javascript code.
Introduction : In this article i will show you how to create DataTable Dynamically in c# .Many times we require to create a DataTable Dynamically in our code .It is very easy you just need to declare all the DataColumn and need to add in Datatable.
Dynamic DataTable code in c# :
//--Decalration Of Data Table ---//
DataTable Dt = new DataTable();
//--Decalration Of Data Column-----//
DataColumn DCID = new DataColumn("ID", typeof(Int32));
DataColumn DCName = new DataColumn("Name", typeof(String));
DataColumn DCCustomerID = new DataColumn("CustomerID", typeof(Int32));
//-- Add Data Column to DataTable --//
Dt.Columns.Add(DCID);
Dt.Columns.Add(DCName);
Dt.Columns.Add(DCCustomerID);
//-- Add Data Rows to DataTable --//
DataRow Dr1 = Dt.NewRow();
Dr1["ID"] = 1;
Dr1["Name"] = "Hamid Seta";
Dr1["CustomerID"] = 1;
DataRow Dr2 = Dt.NewRow();
Dr2["ID"] = 2;
Dr2["Name"] = "Ankur Shah";
Dr2["CustomerID"] = 2;
Dt.Rows.Add(Dr1);
Dt.Rows.Add(Dr2);