How to bind data to repeater without postback RRS feed

  • Question

  • User669521406 posted

    so i have created a repeater, which display duration of each product, now i want that the when a duration finish, it remove the item without postback can someone help please

    here are my code

    Imports System.Data
    Imports System.Data.SqlClient
    Imports System.Configuration
    Imports System.Net.Mail
    Imports System.Web.Configuration
    Imports System.Web.Script.Services
    Imports System.Web.Services
    Partial Class Test
        Inherits System.Web.UI.Page
        Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("VirgoPlaza").ToString())
        Dim EndDate As DateTime
        Dim auction As Integer
        Private ReadOnly _start As String
        Public Sub New()
            _start = WebConfigurationManager.ConnectionStrings("VirgoPlaza").ConnectionString
        End Sub
        Public Function GenerateURL(ByVal Auction As Object) As String
            'Create URL for each product link
            Dim strProdUrl As String = "Wishlist.aspx?Pid=" & Auction
            Return strProdUrl
        End Function
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If Not Page.IsPostBack Then
            End If
        End Sub
        Protected Sub Timer1_Tick(ByVal sender As Object, ByVal e As EventArgs)
            '--this method will fetch the end date from repeater item label and update the duration
        End Sub
        Private Sub UpdateDuration()
            For Each item As RepeaterItem In repItems.Items
                Dim hidden = TryCast(item.FindControl("HiddenField1"), HiddenField)
                Dim label2 = TryCast(item.FindControl("lblTimer"), Label)
                'Grab your DateTime object (checking that it exists)'
                'Store your TimeSpan Difference'
                Dim ts = (DateTime.Now - DateTime.Parse(hidden.Value))
                Dim travelTime As New TimeSpan(0, 0, 0, 0)
                Dim result2 As Integer = TimeSpan.Compare(ts, travelTime)
                If result2 <= 0 Then
                    'Now you can output your time as you please (excluding any decimal points)'
                    label2.Text = String.Format("Time Left: {0:dd\:hh\:mm\:ss}", ts)
                    label2.Text = String.Format("{0:dd\:hh\:mm\:ss}", ts)
                    label2.Text = Replace(label2.Text, ":", " Days ", , 1)
                    label2.Text = Replace(label2.Text, ":", " Hours ", , 1)
                    label2.Text = Replace(label2.Text, ":", " Mins ", , 1)
                    label2.Text = Replace(label2.Text, ":", " Sec ", , 1)
                    timer1.Enabled = True
                End If
        End Sub
        Private Sub BindItems()
            Using con1 As New SqlConnection(_start)
                Dim sql1 As String = "[StoredProcedure2]"
                Dim myCommand1 As New SqlCommand(sql1, con1)
                myCommand1.CommandType = CommandType.StoredProcedure
                myCommand1.Parameters.AddWithValue("@endate", DateTime.Now)
                Dim category As SqlDataReader
                category = myCommand1.ExecuteReader()
                'binding data from category table to ddlcategory
                repItems.DataSource = category
            End Using
    <%@ Page Title="" Language="VB" MasterPageFile="~/Part1/MasterPage.master" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
      <asp:ScriptManager ID="ScriptManager1" runat="server" />
             <asp:repeater id="repItems"  runat="server">
              <li><center> <a href="../ProductDetails/ProductDetailOffline.aspx?ItemID=<%# Eval("ItemID") %>"> <asp:Image id="Image1" runat="server" ImageUrl='<%# Eval("Image")%>' /></a></center>
                <div class="product-info">
                       <asp:Label ID="Label1" runat="server" Text='<%# Eval("Name")%>'></asp:Label> </h3>
                  <div class="product-desc">
                    <table width="200px" border="0">
                            <td align="center" style="background-color:#7F7F7F; color:White;">Price</td>
                            <td align="center">Rs.&nbsp;<asp:Label ID="Label4" Text='<%#String.Format("{0:###,###.00}", Eval("CurrencyValuePost"))%>' runat="server" Font-Bold="true" /></td>
                            <td align="center"  style="background-color:#7F7F7F; color:White;">
                                Time Left
                            <td align="center">
                               <asp:UpdatePanel id="updPnl" runat="server" UpdateMode="Conditional">
                                        <asp:Label ID="lblTimer"   runat="server"></asp:Label>
                                        <asp:asyncpostbacktrigger ControlID="timer1" eventname="tick" />
                      <asp:Label ID="lblauction" Visible="false" Text='<%#Eval("AuctionID")%>' runat="server" />
                      <asp:Label ID="lblEndDate" Visible="false" Text='<%#Eval("EndDate")%>' runat="server" />
                     <asp:HiddenField ID="HiddenField1" Value='<%#Eval("EndDate")%>' runat="server" />
                      <a href='<%#GenerateURL(Eval("AuctionID"))%>' style="border: 0 none white">
                    <br/> <p></a>
              <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                     <asp:Timer ID="timer1" Interval="1000" Enabled="true" OnTick="timer1_tick" runat ="server">
    <asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">

    Friday, January 31, 2014 4:16 AM