In this Example, we are using the pager template for paging.

DataKeyNames – Used for Getting Row in Row command.
Set the AllowPaging is to True and Set the PageSize is to your Page size count.
Eval – Used for Direct column Binding .

Within that script tag Container.DataItemIndex is used for Serial No.

Images for Paging

First.jpg
Last.jpg
Next.jpg
 Previous.jpg



In Aspx Page,

<asp:GridView ID="gvEdit" runat="server" AutoGenerateColumns="False" DataKeyNames="LOBID" OnPageIndexChanging="gvEdit_PageIndexChanging" Width="100%" AllowPaging="True" PageSize="10" OnRowCommand="gvEdit_RowCommand" OnRowCreated="gvEdit_RowCreated" OnRowEditing="gvEdit_RowEditing">

<HeaderStyle HorizontalAlign="Center" BackColor="#2D96CE" ForeColor="White"/>
<AlternatingRowStyle BackColor="#D4EFFD" />

<Columns>

<asp:TemplateField HeaderText="S.No.">
<ItemTemplate>
<asp:LinkButton Style="color:Maroon;font-size:small" ID="lnkSno" runat="Server" Text='<%# Container.DataItemIndex + 1 %>' CommandName="Edit">
</asp:LinkButton>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField HeaderText="LOBID" Visible="false">
<ItemTemplate>
<asp:Label ID="lblLOBID" runat="Server" Text='<%# Eval("LOBID") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="left" />
</asp:TemplateField>

<asp:TemplateField HeaderText="LOB Name">
<ItemTemplate>
<asp:Label ID="lblLOBName" runat="Server" Text='<%# Eval("LOB") %>'></asp:Label></ItemTemplate>
<ItemStyle HorizontalAlign="left" />
</asp:TemplateField>

<asp:TemplateField HeaderText="Customer">
<ItemTemplate>
<asp:Label ID="lblCustomer" runat="Server" Text='<%# Eval("Customer") %>'></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="left" />
</asp:TemplateField>
</Columns>

<PagerStyle Height="8px" HorizontalAlign="Center" />
<PagerTemplate>
<table style="width: 100%;" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="right" style="width: 60%;">
<table>
<tr>
<td>
<asp:ImageButton ToolTip="First Page" CommandName="Page" CommandArgument="First" runat="server" ID="ImgeBtnFirst" ImageUrl="../Images/First.jpg" />
</td>

<td>
<asp:ImageButton ToolTip="Previous Page" CommandName="Page" CommandArgument="Prev" runat="server" ID="ImgbtnPrevious" ImageUrl="../Images/Previous.jpg" />
</td>
<td>
<asp:DropDownList ToolTip="Goto Page" ID="ddlPageSelector" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlPageSelector_SelectedIndexChanged" CssClass="combo_common_nowidth">
</asp:DropDownList>
</td>
<td>
<asp:ImageButton ToolTip="Next Page" CommandName="Page" CommandArgument="Next" runat="server" ID="ImgbtnNext" ImageUrl="../Images/Next.jpg" />
</td>
<td>
<asp:ImageButton ToolTip="Last Page" CommandName="Page" CommandArgument="Last" runat="server" ID="ImgbtnLast" ImageUrl="../Images/Last.jpg" />
</td>
</tr>
</table>
</td>
<td style="width: 40%" align="right">
<asp:Label ID="lblpageindx" CssClass="labelBold" Text="Page : " runat="server"></asp:Label>
</td>
</tr>
</table>
</PagerTemplate>
</asp:GridView>

In Code Behind(.cs file) contains the following codes,

Here objLoad is a BusinessLayer Object.

//GridView Binding Call

/// <summary>
/// Bind the Customer LOB Mapping
/// </summary>
private void BindEdit()
{
  objLoad.LOBID = Convert.ToInt32(ddlSearchLOB.SelectedValue);
  objLoad.Customer = ddlSearchCustomer.SelectedValue;
  DataSet objSet = new DataSet();
  objSet = objLoad.GetCustomerMapping();
  gvEdit.DataSource = (objSet.Tables.Count != 0 ? objSet.Tables[0] : null);
        gvEdit.DataBind();
        if (gvEdit.Rows.Count == 0)
        {
          lblMsg.Text = "Oops! No Records Found.";
          lblMsg.Visible = true;
  }
}


//Set the Pager Row here.

protected void gvEdit_RowCreated(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.Pager)
   {
     SetPagerButtonStates(gvEdit, e.Row, this, "ddlPageSelector");
   }
 }



//Get the Index no. from Page DropdownList and Bind the current page.

protected void ddlPageSelector_SelectedIndexChanged(object sender, EventArgs e)
{
  gvEdit.PageIndex = ((DropDownList)sender).SelectedIndex;
  BindEdit();
}

//GridView Page Index Changing and Bind the current Page index

protected void gvEdit_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    gvEdit.PageIndex = e.NewPageIndex;
    BindEdit();
}

//RowCommand Edit for Updation, Hyperlink button click event.

protected void gvEdit_RowCommand(object sender, GridViewCommandEventArgs e)
{

try
{
if (e.CommandName == "Edit")
{

GridViewRow row =   (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
Label lblLOBID = row.Cells[1].FindControl("lblLOBID") as Label;
Label lblCustomer = row.Cells[3].FindControl("lblCustomer") as Label;
hidEdit.Value = lblLOBID.Text + "~" + lblCustomer.Text;
ddlLOB.SelectedIndex = -1;
ddlCustomer.SelectedIndex = -1;
ddlLOB.SelectedValue = lblLOBID.Text;
ddlCustomer.SelectedValue = lblCustomer.Text;
}
}
catch (Exception ex)
{
}
       
}

//Set the Page settings and add the page numbers for Paging

/// <summary>
/// Setting the Pager
/// </summary>
/// <param name="gridView">Gridview Control ID</param>
/// <param name="gvPagerRow">GridView Row</param>
/// <param name="page">Page</param>
/// <param name="DDlPager">Drop down list ID</param>

public void SetPagerButtonStates(GridView gridView, GridViewRow gvPagerRow, Page page, string DDlPager)
{
  // to Get No of pages and Page Navigation
  int pageIndex = gridView.PageIndex;
  int pageCount = gridView.PageCount;
  ImageButton btnFirst = (ImageButton)gvPagerRow.FindControl("ImgeBtnFirst");
  ImageButton btnPrevious = (ImageButton)gvPagerRow.FindControl("ImgbtnPrevious");
  ImageButton btnNext = (ImageButton)gvPagerRow.FindControl("ImgbtnNext");
  ImageButton btnLast = (ImageButton)gvPagerRow.FindControl("ImgbtnLast");
  btnFirst.Enabled = btnPrevious.Enabled = (pageIndex != 0);
  btnNext.Enabled = btnLast.Enabled = (pageIndex < (pageCount - 1));
  DropDownList ddlPageSelector = (DropDownList)gvPagerRow.FindControl(DDlPager);
  ddlPageSelector.Items.Clear();
  for (int i = 1; i <= gridView.PageCount; i++)
  {
     ddlPageSelector.Items.Add(i.ToString());
  }
  ddlPageSelector.SelectedIndex = pageIndex;
  string strPgeIndx = Convert.ToString(gridView.PageIndex + 1) + " of " 
                      + gridView.PageCount.ToString();
 
  Label lblpageindx = (Label)gvPagerRow.FindControl("lblpageindx");
  lblpageindx.Text += strPgeIndx;
}


The output looks like below,


string sRootDirectory = Server.MapPath(".").Substring(0, Server.MapPath(".").LastIndexOf(@"\")); ;

string sPath = sRootDirectory + @"\" + "App_Themes";
string[] Themes;
Themes = Directory.GetDirectories(sPath);
int ThemeCount = 0;
ThemeCount = Themes.Length;
string[] ddlThemes = new string[ThemeCount];
int iIndex = 0;
int iCount = 0;
foreach (string Theme in Themes)
{
  iIndex = Theme.LastIndexOf(@"\");
  string sTheme;
  sTheme = Theme.Substring(iIndex + 1);
  ddlThemes[iCount] = sTheme;
  iCount++;
}
//Add theme names in Dropdown for selection
ddlTheme.Items.Add(new ListItem("--Select--", "0"));
foreach (string Theme in ddlThemes)
{
   ddlTheme.Items.Add(new ListItem(Theme, "~/Images/" + Theme + ".jpg"));
}
ddlTheme.DataBind();
ddlTheme.Focus();

CREATE TRIGGER trgPFPAmountLog
ON [dbo].[t_PfpAmount]  
AFTER DELETE 
AS 
      INSERT INTO t_PfpAmount_Log
      (
            LocationID,[Month],[Year],
            EmpID,PFPAmount,[System],
            CreatedBy,CreatedOn,
            DBLoginName,SystemIP
      )  
     
      SELECT
                  LocationID,[Month],[Year],
                  EmpID,PFPAmount,[System],CreatedBy,
                  CreatedOn,SYSTEM_USER ,HOST_NAME()
      FROM deleted

  In Job Creation, it does not have directly to backup the DB. Whether we have to use SP or Query to backup the DB. One more efficient way is Maintenance plan it is available under Management Folder.

How to create a Maintenance plan?


Below figure steps explains visually…

Select the Maintenance Wizard

Click Next

Here if you need we will create a Schedule for running and Click Next

Select the DB operation and Click Next

Click Next

Choose DB for Backup and click ok.
sd

Choose the Backup file location like below


Choose the location for action report


 

Click Finish button for completion. Now the Maintenance plan created successfully.


How to Execute this plan in Job


Right click Job Folder and Click New Job… Option.

Then, Follow the below figured steps…


Choose the category as Database Maintenance.

Click for new steps.

General for Tab declaration

Set Values and Command line Tab for execution

Schedules are be like,


In Notification, choose the log,




That’s all, the back will be created each Sunday.