<asp:UpdatePanel ID="updPanel" runat="server" UpdateMode="Conditional"> <ContentTemplate> <mcn:DataPagerGridView ID="gvProducts" runat="server" OnRowDataBound="RowDataBound" AutoGenerateColumns="False" AllowPaging="True" AllowSorting="True" CssClass="datatable" CellPadding="0" BorderWidth="0px" GridLines="None" DataSourceID="SqlDataSource1"> <Columns> <asp:BoundField HeaderText="ID" DataField="Emp_Id" SortExpression="Emp_Id" HeaderStyle-CssClass="first" ItemStyle-CssClass="first"> <HeaderStyle CssClass="first" /> <ItemStyle CssClass="first" /> </asp:BoundField> <asp:BoundField HeaderText="Name" DataField="Emp_Name" SortExpression="Emp_Name" /> <asp:BoundField HeaderText="Quantity" DataField="Emp_Payroll_No" SortExpression="Emp_Payroll_No" /> </Columns> <PagerSettings Visible="False" /> <RowStyle CssClass="row" /> </mcn:DataPagerGridView> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT * FROM [tblemployee]"></asp:SqlDataSource> <!-- Notice this is outside the GridView --> <div class="pager"> <asp:DataPager ID="pager" runat="server" PageSize="8" PagedControlID="gvProducts"> <Fields> <asp:NextPreviousPagerField ButtonCssClass="command" FirstPageText="«" PreviousPageText="‹" RenderDisabledButtonsAsLabels="true" ShowFirstPageButton="true" ShowPreviousPageButton="true" ShowLastPageButton="false" ShowNextPageButton="false" /> <asp:NumericPagerField ButtonCount="7" NumericButtonCssClass="command" CurrentPageLabelCssClass="current" NextPreviousButtonCssClass="command" /> <asp:NextPreviousPagerField ButtonCssClass="command" LastPageText="" NextPageText="›" RenderDisabledButtonsAsLabels="true" ShowFirstPageButton="false" ShowPreviousPageButton="false" ShowLastPageButton="true" ShowNextPageButton="true" /> </Fields> </asp:DataPager> </div> </ContentTemplate> </asp:UpdatePanel>
protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); String strConnString = "Data Source=\\SqlExpress;Initial Catalog=HRDB;User ID=sa;"; SqlConnection con = new SqlConnection(strConnString); SqlDataAdapter sda = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand("tblemployee"); cmd.CommandType = CommandType.Text; cmd.CommandText = sqlquery; cmd.Connection = con; sda.SelectCommand = cmd; sda.Fill(dt); gvProducts.DataSource = dt; gvProducts.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { DataTable dt = new DataTable(); String strConnString = "Data Source=\\SqlExpress;Initial Catalog=HRDB;User ID=sa;"; SqlConnection con = new SqlConnection(strConnString); SqlDataAdapter sda = new SqlDataAdapter(); SqlCommand cmd = new SqlCommand("tblemployee"); cmd.CommandType = CommandType.Text; cmd.CommandText = sqlquery; cmd.Connection = con; sda.SelectCommand = cmd; sda.Fill(dt);
gvProducts
.DataSource = dt;
.DataBind(); }
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: