How can use repeater in C sharp

Firstly Code for reapter in .aspx page
   <div><div class="row ">
<center>
<span class="text-info lead">
Ticket List </span>
</center>
<br><div class="col-xs-12 col-sm-12 col-md-1">
</div><div class="col-xs-12 col-sm-12 col-md-10">
<div class="table-responsive">
<table class="table table-hover table-bordered table-striped">
<asp:Repeater ID="repeaterItems" runat="server">
<HeaderTemplate>
<tr><td >S. No.</td></td><td >Ticket ID</td>
<td> Subject</td><td> Status</td></tr>
</HeaderTemplate>
<ItemTemplate>
<tr><td> <%#Container.ItemIndex+1%></td>
<td>#<%#Eval("ticket_id")%></td>
<td>
<span style="text-transform: uppercase;">
<%#Eval("subject")%></span>
<br /><span class="pull-right" style="font-size:12px;"> <%#Eval("created_by")%> </span></td>
<td> <a href="ticket-detail.aspx?id=<%#Eval("ticket_id")%>" class="<%# (Eval("ticket_status").ToString()=="Open") ? @"btn btn-primary": @"btn btn-danger" %>" ><%#Eval("ticket_status")%></a></td>
</ItemTemplate><FooterTemplate ></tr> </FooterTemplate>
</asp:Repeater> </table> <br /> <center>
<div id="divb" runat="server"></div>
<br /> <asp:Label ID="lblCurrentPage" runat="server" Text=""></asp:Label>
</center></div></div>
<div class="col-xs-12 col-sm-12 col-md-1"></div></div></div>

Repeater code in .aspx.cs page

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

public partial class ticket_list : System.Web.UI.Page
{
    string query, user_flag = "", user_mail = "", user_name = "", user_type = "", result;
    string id, seat;
    int pagecounter;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HttpContext.Current.Session != null || HttpContext.Current.Session.Count > 0)
        {
            if (Session["flag"] == "" || Session["flag"] == null)
            {
                Response.Redirect("index.html");
            }
            else
            {
                user_flag = Session["flag"].ToString();
                user_mail = Session["user"].ToString();
                user_name = Session["name"].ToString();
                user_type = Session["type"].ToString();
            }

        }
        else
        {
            Response.Redirect("index.html");
        }
        if (Request.QueryString["seat"] != "" && Request.QueryString["seat"] != null)
        {
            seat = Request.QueryString["seat"].ToString();
            CurrentPage = (Convert.ToInt32(seat) - 1);

        }

       
        ItemsGet();
    }

    public int CurrentPage
    {
        get
        {
            
            object o = this.ViewState["_CurrentPage"];
            if (o == null)
                return 0;  
            else
                return (int)o;
        }

        set
        {
            this.ViewState["_CurrentPage"] = value;
        }
    }

    private void ItemsGet()
    {
        myconnection consrc = new myconnection();
        SqlCommand cmd = new SqlCommand("st_pro_client_ticket_view  ", consrc.con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("created_by ", user_mail);
       
        consrc.con.Open();
        SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd);
        DataSet dataSet = new DataSet();
        dataAdapter.Fill(dataSet);
       
        PagedDataSource objPds = new PagedDataSource();

        objPds.DataSource = dataSet.Tables[0].DefaultView;
        objPds.AllowPaging = true;
        objPds.PageSize = 50;

        objPds.CurrentPageIndex = CurrentPage;

        lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
           + objPds.PageCount.ToString();
        pagecounter = objPds.PageCount;
       
        repeaterItems.DataSource = objPds;
        repeaterItems.DataBind();
        button_create();
    }

    private void button_create()
    {
        int cp = CurrentPage;
        int lp = pagecounter;
        int j;
        int m1;
        int m2;
        string prev, last;
        if (cp + 10 > lp)
        {
            m1 = lp;
        }
        else
        {
            m1 = cp + 10;
        }

        if (cp - 10 < 1)
        {
            m2 = 1;
        }
        else
        {
            m2 = cp - 10;
        }
        if (cp < 1)
        {
            prev = "
  • «
  • "; } else { prev = "
  • «
  • "; } if (lp == cp + 1) { last = "
  • »
  • "; } else { last = "
  • »
  • "; } string joint1 = "
      "; string joint2 = "
    "; string linktotal = ""; for (j = m2; j <= m1; j++) { string link1 = ""; if (j == cp + 1) { link1 = "class=\"active\""; } else { } string link2 = "
  • " + j.ToString() + "
  • "; linktotal = linktotal + link2; } divb.InnerHtml = joint1 + prev + linktotal + last + joint2; } void newbtnclick(object sender, EventArgs e) { Button btm = (Button)sender; CurrentPage = (Convert.ToInt32(btm.Text) - 1); ItemsGet(); } public string MYFUN(string abc) { abc = abc.Replace(' ', '-'); return abc; } }

    Share on facebook Google Twitter

    Web Engineers here !


    Grideb is the group of engineers who provide excellent solution for domain scenario with experienced, talented and high skilled engineers. We work hard to reduce complication of user interface and improve better quality of service.

    -- Chief Executive Officer, GRIDEB SERVICES


    www.grideb.com

    Contact Us

    GRIDEB SERVICES
    Office-1,FF ,One Square Office Mall
    Shaktikhand-III,Indirapuram,Ghaziabad
    Uttar Pradesh 201004 (INDIA)
    P: +91 (120) 260-6044
    M: +91 90-1300-3421
    Email ID
    info@grideb.com




    Grideb Services 2013-2014