Friday, May 17, 2013

Gridview inside gridview || Nested gridview in Asp.net

Title:How to use grid view inside grid view in asp.net using c#.net

Description:
Earlier we have seen how to Export grid view data to PDF,Bind data to grid view in asp.net.Here i will given an example for how to develop the nested grid view in asp.net.In this example the binding has done while page load event then the child grid view will populate on row data bound event.
Example:

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Gridview inside gridview or Nested GridView in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GvParentOrderReport" runat="server" OnRowDataBound="GvOrderReport_RowDataBound"
AllowPaging="True" AutoGenerateColumns="False" DataKeyNames="OrderId"
GridLines="Horizontal">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:BoundField DataField="Orderid" HeaderText="OrderId">
</asp:BoundField>
<asp:BoundField DataField="OrderName" HeaderText="OrderName" >
</asp:BoundField>
<asp:BoundField DataField="Phone" HeaderText="Phone" >
</asp:BoundField>
<asp:BoundField DataField="Address" HeaderText="Address" >
</asp:BoundField>
<asp:BoundField DataField="Amount" HeaderText="Amount" >
</asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<tr>
<td>
<asp:GridView ID="GvChildOrderNested" runat="server" AutoGenerateColumns="false">
<Columns>
<asp:BoundField DataField="OrderId" HeaderText="OrderID"/>
<asp:BoundField DataField="OrderName" HeaderText="OrderName"/>
<asp:BoundField DataField="Phone" HeaderText="Phone"/>
<asp:BoundField DataField="Address" HeaderText="Address"/>
<asp:BoundField DataField="Amount" HeaderText="Amount"/>
</Columns>
</asp:GridView>
</div>
</td>
</tr>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</form>
</body>
</html>

using System;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public partial class _GridviewInsideGridview : System.Web.UI.Page
{
SqlConnection mcon = new SqlConnection("Data Source=Bhaskar\sqlexpress;Initial Catalog=Test;Integrated Security=True");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
mcon.Open();
SqlCommand Parentcmd = new SqlCommand("select * from orders", mcon);
SqlDataAdapter Parentda = new SqlDataAdapter(Parentcmd);
DataSet Parentds = new DataSet();
Parentda.Fill(Parentds);
mcon.Close();
GvParentOrderReport.DataSource = Parentds;
GvParentOrderReport.DataBind();
}
}
     
protected void GvOrderReport_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
mcon.Open();
GridView GvChildOrderNested = (GridView)e.Row.FindControl("GvChildOrderNested");
SqlCommand Childcmd = new SqlCommand("select * from orders", mcon);
SqlDataAdapter Childda = new SqlDataAdapter(Childcmd);
DataSet Childds = new DataSet();
Childda.Fill(Childds);
mcon.Close();
GvChildOrderNested.DataSource = Childds;
GvChildOrderNested.DataBind();
}
}
}

Wednesday, May 15, 2013

How to bind data to gridview with jquery in asp.net

In previous articles i have given Cascading dropdownlist using jquery .In this post i would like to explain how to bind data to gridview using Jquery. Here we can observe the page method calling using jquery post method
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Bind data to grid using jquery in asp.net</title>
<script src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script>
<script type="text/javascript">
$(document).ready(function () {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "JqueryBindGrid.aspx/BindOrderDataToGrid",
data: "{}",
dataType: "json",
success: function (resData) {
    for (var i = 0; i < resData.d.length; i++) {
        $("#GvOrderDetails").append("<tr><td>" + resData.d[i].OrderId + "</td><td>" + resData.d[i].OrderName + "</td><td>" + resData.d[i].Phone + "</td><td>" + data.d[i].Address + "</td><td>" + resData.d[i].Amount + "</td></tr>");
}
},
error: function (result) {
alert("Exception");
}
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GvOrderDetails" runat="server">
</asp:GridView>
</form>
</body>
</html>
Code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Web.Services;

public partial class JqueryBindGrid : System.Web.UI.Page
{
  
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable GVHeaderdt = new DataTable();
GVHeaderdt.Columns.Add("OrderId");
GVHeaderdt.Columns.Add("OrderName");
GVHeaderdt.Columns.Add("Phone");
GVHeaderdt.Columns.Add("Address");
GVHeaderdt.Columns.Add("Amount");
GVHeaderdt.Rows.Add();
GvOrderDetails.DataSource = GVHeaderdt;
GvOrderDetails.DataBind();
      
}
}
public class OrderReportDetails
{
public int OrderId { get; set; }
public string OderName { get; set; }
public string Phone { get; set; }
public string Address { get; set; }
public string Amount { get; set; }
}
[WebMethod]
public static OrderReportDetails[] BindOrderDataToGrid()
{
DataTable resDt = new DataTable();
List ORdetails = new List();
SqlConnection Dbcon = new SqlConnection(ConfigurationManager.AppSettings["DbOrdrCon"].ToString());
SqlCommand cmd = new SqlCommand("select * from Orders", Dbcon);
Dbcon.Open();
SqlDataAdapter Orda = new SqlDataAdapter(cmd);
Orda.Fill(resDt);
foreach (DataRow Ordt in resDt.Rows)
{
    OrderReportDetails OrderDetails = new OrderReportDetails();
    OrderDetails.OrderId = int.Parse(Ordt["OrderId"].ToString());
    OrderDetails.OderName = Ordt["OrderName"].ToString();
    OrderDetails.Phone = Ordt["Phone"].ToString();
    OrderDetails.Address = Ordt["Address"].ToString();
    OrderDetails.Amount = Ordt["Amount"].ToString();
    ORdetails.Add(OrderDetails);
}
Dbcon.Close();
return ORdetails.ToArray();
}
  
}

Tuesday, May 14, 2013

how to bind arraylist to gridview in asp.net

In previous articles we have seen how to bind the data to grid view, Bind data to dropdownlist,Bind data to dropdownlist in gridview,Export gridview to PDF.Here i would like to explain how to bind arraylist data to Grid view in asp.net.In the below i have used static array list for binding
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ArrayListToGridview.aspx.cs" Inherits="_ArrayListToGridview" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Bind ArrayList to Gridview</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GvBindArrayList" runat="server"
AutoGenerateColumns="False" >
</asp:Gridview>
</form>
</body>
</html>

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.IO;
using System.Collections.Generic;
using System.Linq;

public partial class _ArrayListToGridview : System.Web.UI.Page
{
protected void Page_Load(Object Sender, EventArgs E)
{
if (!IsPostBack) {
ArrayList Booknames = new ArrayList();
Booknames.Add ("Asp.net");
Booknames.Add ("C#.net");
Booknames.Add ("SharePoint");
Booknames.Add ("SqlServer");
Booknames.Add ("Jquery");
Booknames.Add ("Asp.netMVC");
GvBindArrayList.DataSource = Booknames;
GvBindArrayList.DataBind();
}
}
}

Monday, May 13, 2013

jquery redirect to another page in asp.net

Title:How to redirect the from one page to other page in asp.net using Jquery

Description:
Basically the scripting language are used to perform dynamic data processing on client side.It will be improve the performance of application
Example:
In previous examples i have given Validate dropdownlist using Jquery,JqueryUI Autocomplete textbox,Jquery Modal popup for mail in asp.net,Jquery Get next/previous month of year.Here i would like explain how to redirect to other page when click on the button in Asp.net using jquery. We can use location method in two ways as you can see in the script
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src=http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js></script>
<script type="text/javascript">
$(document).ready(function () {
$('#btnRedirect').click(function () {
window.location.href = 'About.aspx';
// or you can use
// location.href = 'About.aspx';
return false;
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnRedirect" runat="server" Text="Redirect" />
</form>
</body>
</html>

Sunday, May 12, 2013

how to export gridview to csv file in asp.net

Title: How to export grid view data to CSV or Text file in asp.net using c#.net

Description:
As per previous articles we have seen how to Bind CSV data to Grid view in asp.net,Export Grid view Data to Word Document,Export Grid view data to PDF document,Import XML data to GridView in Asp.net .Here i would like explain about how to export grid view data to CSV file in asp.net.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Export2CSV.aspx.cs" Inherits="Export2CSV" EnableEventValidation="false" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GvOrderDetails" runat="server" AutoGenerateColumns="False" >
</asp:GridView>
<asp:Button ID="btnExportCSV" runat="server" Text="Gridview To CSV" onclick="btnExportCSV_Click" />
<div>
</div>
</form>
</body>
</html>
Code behind:In the below Grid view data bind has done while page loading.when we fire click event the data colud be export to CSV file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;


public partial class Export2CSV : System.Web.UI.Page
{
SqlConnection Econ = new SqlConnection(ConfigurationManager.ConnectionStrings["Exportconn"].ToString());
DataSet ds = new DataSet();
  
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlCommand cmd = new SqlCommand("select * from orders", Econ);
SqlDataAdapter Gda = new SqlDataAdapter(cmd);
Gda.Fill(ds);
GvOrderDetails.DataSource = ds;
GvOrderDetails.DataBind();
}
}

protected void btnExportCSV_Click(object sender, EventArgs e)
{
     
SqlDataAdapter Cda = new SqlDataAdapter("SELECT* FROM Orders",Econ);
DataTable Gdt = new DataTable();
Cda.Fill(ds);
    //Bind data to Data table
Gdt = ds.Tables[0];
StreamWriter Exportsw = new StreamWriter("E:\\OrderCSVReport.csv", false);
int CSVCount = Gdt.Columns.Count;
for (int i = 0; i < CSVCount; i++)
{
Exportsw.Write(Gdt.Columns[i]);
if (i < CSVCount - 1)
{
Exportsw.Write(",");
}
}
Exportsw.Write(Environment.NewLine);

foreach (DataRow Gdr in Gdt.Rows)
{
for (int i = 0; i < CSVCount; i++)
{
if (!Convert.IsDBNull(Gdr[i]))
{
Exportsw.Write(Gdr[i].ToString());
}
if (i < CSVCount - 1)
{
Exportsw.Write(",");
}
}
Exportsw.Write(Environment.NewLine);
}
Exportsw.Close();
}
}
}

Wednesday, May 8, 2013

cascading dropdownlists in asp.net MVC4

Title:
Cascading DropDownList in Asp.net MVC

Description:
AS we discussed in about cascading drop down in asp.net ,this articles will also describe the same functionality using model view controller frame work.Before going to read this article ,we should have some basic knowledge on Jquery and MVC patters.

Example:
What we have discussed in previous articles is cascading dropdownlist in asp.net,Required Validations Asp.net MVC4 ,Bind data to dropdownlist in MVC,jquery reference mvc.Now i would like explain how to develop cascading dropdownlist in MVC4.For you need to do the step by step process as per below code

View:
@{
ViewBag.Title = "Cacading Dropdownlist in Asp.net MVC4";
}
@using (Html.BeginForm())
{
<fieldset>
<legend></legend>
@Html.Label("CodeBook")
@Html.DropDownList("CodeBook", ViewBag.CodeBookRes as SelectList, "Select a CodeBook", new { id = "CodeBook" })
@Html.Label("Versions")
<select id="Versions"  name="Versions"></select>
</fieldset>
}

@Scripts.Render("~/bundles/jquery")
<script type="text/jscript">
$(function () {
$('#CodeBook').change(function () {
$.getJSON('/Cascading/VersionResList/' + $('#CodeBook').val(), function (data) {
var Listitems = '<option>please Select CodeBook</option>';
$.each(data, function (i, Versions) {
Listitems += "<option value='" + Versions.Value + "'>" + Versions.Text + "</option>";
});
$('#Versions').html(Listitems);
});
});
});
</script>
MVC4CacadingController:
This controller has two methods one is return the list and other one return the JSON result.The json result will call when make selection of Book dropdown
using CascadingDropdownlistMVC4.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace CascadingDropdownlistMVC4.Controllers
{
public class CascadingController : Controller
{
//
// GET: /Cascading/
public ActionResult Index()
{
List CodeBooks = new List();
CodeBooks.Add(new SelectListItem { Text = "Asp.netMVC", Value = "Asp.netMVC" });
CodeBooks.Add(new SelectListItem { Text = "Sharepoint", Value = "Sharepoint" });
CodeBooks.Add(new SelectListItem { Text = "SqlServer", Value = "SqlServer" });
CodeBooks.Add(new SelectListItem { Text = "Asp.net", Value = "Asp.net" });
CodeBooks.Add(new SelectListItem { Text = "C#.net", Value = "C#.net" });
ViewBag.CodeBookRes = new SelectList(CodeBooks, "Value", "Text");
return View();
}

public JsonResult VersionResList(string Id)
{
var VersionRes = from vs in VersioList.GetVersion()
where vs.Book == Id
select vs;
return Json(new SelectList(VersionRes.ToArray(), "Book", "Version"), JsonRequestBehavior.AllowGet);
}
}
}
Set Proprties:In this class i have created variable and set the propeties
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CascadingDropdownlistMVC4.Models
{
public class SetProperties
{
public string CodeBooks { get; set; }
public string Versions { get; set; }
}

public class VersionList
{
public string Book { get; set; }
public string Version { get; set; }

public static IQueryable GetVersion()
{
return new List
{
new VersionList { Book= "Asp.netMVC", Version= "MVC3" },
new VersionList { Book= "Asp.netMVC", Version= "MVC4" },
new VersionList { Book= "SqlServer", Version = "2008R2" },
new VersionList { Book= "SqlServer", Version = "2012" },
new VersionList { Book= "Sharepoint", Version= "2010" },
new VersionList { Book= "Sharepoint", Version = "2013" },
new VersionList { Book= "Asp.net", Version = "4.0" },
new VersionList { Book= "Asp.net", Version = "4.5" },
new VersionList { Book= "c#.net", Version = "4.0" },
new VersionList { Book= "C#.net", Version = "4.5" },
}.AsQueryable();
}
}
}

Monday, May 6, 2013

how to export gridview data to pdf in asp.net

Title: How to export grid view data to PDF in asp.net

Description:
Most the report are send to customers as in excel format.But some scenarios they might ask PDF format.

Example:
Earlier we learned how to export grid view data to word document,Import excel data to SQL Server.In this post i will show how to export grid view data to PDF file in asp.net.While exporting to pdf i have created a pdf document with desired size .Then conversion has done using HTML parser
Note:itextsharp tool has been used.so we need add those DLL into our application
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportToPDF.aspx.cs" Inherits="_ExportToPDF" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Export Gridview To PDF documnet</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GvExportDetails" runat="server"
AutoGenerateColumns="False" DataSourceID="SqlDataSource1" EnableModelValidation="True"
>
<Columns>
<asp:BoundField DataField="ExportOrderID"
                 HeaderText="ExportOrderID" SortExpression="ExportOrderID"/>
<asp:BoundField DataField="ExportOrderName"
                HeaderText="ExportOrderName" SortExpression="ExportOrderName"/>
<asp:BoundField DataField="ExportPhone" HeaderText="ExportPhone" SortExpression="ExportPhone" />
<asp:BoundField DataField="ExportAddress" HeaderText="ExportAddress" SortExpression="ExportAddress" />
<asp:BoundField DataField="ExportAmount" HeaderText="ExportAmount" SortExpression="ExportAmount" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>
</div>
<asp:Button ID="btnExportOrdersToPdf" runat="server"
             OnClick="btnExportOrdersToPdf_Click"
             Text="OrderDetails to PDF" />
</form>
</body>
</html>
Code behind:
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data;
using System.IO;
using System.Data.SqlClient;
using iTextSharp.text;
using iTextSharp.text.pdf;
using iTextSharp.text.html.simpleparser;

public partial class _ExportToPDF : System.Web.UI.Page 
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnExportOrdersToPdf_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=OrderDetailsReport.pdf");
Response.Charset = string.Empty;
Response.ContentType = "application/vnd.pdf";
StringWriter swr = new StringWriter();
HtmlTextWriter hwr = new HtmlTextWriter(swr);
GvExportDetails.RenderControl(hwr);
StringReader srd = new StringReader(swr.ToString());
Document OrderDetialsReport = new Document(PageSize.A1, 12f, 12f, 12f, 10f);
HTMLWorker _htmlparser = new HTMLWorker(OrderDetialsReport);
PdfWriter.GetInstance(OrderDetialsReport, Response.OutputStream);
OrderDetialsReport.Open();
_htmlparser.Parse(srd);
OrderDetialsReport.Close();
Response.Write(OrderDetialsReport);
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}
  
}
Note:Errors might be come like "registerforeventvalidation can only be called during render"

Sunday, May 5, 2013

Export gridview data to word document in asp.net

Title:How to export data from grid view to word document in asp.net using c#

Description:
As per previous articles we have learnt the reporting is the mandatory step for any web application.The data can be exported in different formats like PDF,Excel etc,Now i would like to explain on export data to word document from grid view

Example:
What we have read :
how to export grid view to excel,bind excel data to grid view in asp.net.Here this example will describe how to export Grid view data to word document in asp.net.

<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<asp:GridView ID="gvOrder" AllowSorting="True" AllowPaging="True" Runat="server" AutoGenerateEditButton="True" AutoGenerateDeleteButton="True"
AutoGenerateColumns="False" DataSourceID="OrdrDb">
<Columns>
<asp:BoundField DataField="OrderID" HeaderText="OrderID"/>
<asp:BoundField DataField="OrderName" HeaderText="OrderName"/>
<asp:BoundField DataField="Phone" HeaderText="Phone"/>
<asp:BoundField DataField="Address" HeaderText="Address"/>
<asp:BoundField DataField="Amount" HeaderText="Amount"/>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="OrdrDb" runat="server"
ConnectionString="<%$ ConnectionStrings:TestConnectionString %>"
SelectCommand="SELECT * FROM [Orders]"></asp:SqlDataSource>
<asp:Button ID="btnexportOrderstoWord" runat="server" Text="Button"
onclick="btnexportOrderstoWord_Click" />
</form>
</body>
</html>

Code behind:
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

public partial class ExporttoWord : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnexportOrderstoWord_Click(object sender, EventArgs e)
{
Response.Clear();
Response.Buffer = true;
Response.AddHeader("content-disposition",
"attachment;filename=gvOrderToWord.doc");
Response.ContentType = "application/vnd.ms-word ";
StringWriter swr = new StringWriter();
HtmlTextWriter hwr = new HtmlTextWriter(swr);
gvOrder.AllowPaging = false;
gvOrder.DataBind();
gvOrder.RenderControl(hwr);
Response.Write(swr.ToString());
Response.Flush();
Response.End();
}
public override void VerifyRenderingInServerForm(Control GvOrder)
{
}
}
Note:While executing this class we may get this kind of error because of render control.please click here for solution "RegisterForEventValidation can only be called during Render"

Friday, May 3, 2013

RegisterForEventValidation can only be called during Render in asp.net

In previous post i have given how to Export Gridview data to excel in asp.net,Read data from excel file,Bind excel data to gridview,Export gridview data to word document.In this post i will explain how to resolve the RegisterForEventValidation error while generating reports from gridview.To resolve this kind of  error we need to render the controls then add the set the EnableEventValidation property to False at Page directive(you see the highlighted text).

Code behind:
This peace of code have to add in class.It will render the control to desired response while working with controls

public override void VerifyRenderingInServerForm(Control control)
{
}

HTML:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportToWord.aspx.cs" Inherits="ExportToWord" EnableEventValidation="false"
%>

Thursday, May 2, 2013

gridview paging and sorting without postback in asp.net


In previous articles we have seen Bind data to dropdownlist in gridview,edit,delete,update in grdivew.In this post i will show how to avoid the post back while doing the sorting and paging in gridview.For this we need the set the EnableSortingAndPagingCallbacks to true,then it can perform client side callbacks to fetch the data.If we are using Template field.This property can not support.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Gridview Paging and Sorting with out postback</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GvSales" AllowSorting="True" Runat="server"
 EnableSortingAndPagingCallbacks="true" AllowPaging="true" 
AutoGenerateColumns="False" DataSourceID="SalesDb" 
       PageSize="4">
<Columns>
            <asp:BoundField DataField="SalesID" HeaderText="SalesID"
                 SortExpression="SalesID" />
             <asp:BoundField DataField="SalesPersonName" HeaderText="SalesPersonName"
                SortExpression="SalesPersonName" />
             <asp:BoundField DataField="SaleCity" HeaderText="SalesCity" SortExpression="SaleCity" />
             <asp:BoundField DataField="SalesAmt" HeaderText="Samount"
                 SortExpression="Samount" />
          </Columns>
       </asp:GridView>
<asp:SqlDataSource ID="SalesDb" runat="server"
            ConnectionString="<%$ ConnectionStrings:bhaskarConnectionString %>"
            SelectCommand="SELECT * FROM [Sales_Orders]"></asp:SqlDataSource>
 </div>
 </form>
</body>
</html>
Paging and sorting in Gridview

Bel