can i bind repeater without page load in vb.net??
please share examples..
Loading
can i bind repeater without page load in vb.net??
please share examples..
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Amit MohantyRank #112 · 20K reputationPosted Feb 12, 2024, 7:19 AM EST
If your purpose is to show data only then you can use html table instade of repeater control.
For example:
.price { color: burlywood; } $(document).ready(function () { // Fetch data initially fetchDataAndUpdateTable(); // Refresh data every 1 seconds setInterval(fetchDataAndUpdateTable, 1000); }); function fetchDataAndUpdateTable() { $.ajax({ type: "POST", url: "Default.aspx/GetUpdatedPrices", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { var data = JSON.parse(response.d); document.getElementById('tblDetails').innerHTML = ` Product Id Product Name Product Price `; $.each(data, function (index, item) { document.getElementById('tblDetails').innerHTML += ` ${item.ProductID} ${item.ProductName} ${item.Price} `; }); }, failure: function (response) { console.error('Error fetching data:', response); } }); } Product Id Product Name Product PriceImports System.Data.SqlClient Imports System.Web.Script.Serialization Imports System.Web.Script.Services Imports System.Web.Services Public Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load End Sub Public Shared Function GetUpdatedPrices() As String Dim updatedProducts As New List(Of Product)() Dim connectionString As String = "Data Source=.;Initial Catalog=TestingDB;Integrated Security=SSPI;" Using connection As New SqlConnection(connectionString) Dim query As String = "SELECT ID, Name, Price FROM Products" Using command As New SqlCommand(query, connection) connection.Open() Using reader As SqlDataReader = command.ExecuteReader() While reader.Read() Dim product As New Product() product.ProductID = Convert.ToInt32(reader("ID")) product.ProductName = reader("Name").ToString() product.Price = Convert.ToDecimal(reader("Price")) updatedProducts.Add(product) End While End Using End Using End Using ' Return updatedProducts Dim serializer As New JavaScriptSerializer() Return serializer.Serialize(updatedProducts) End Function End Class Public Class Product Public Property ProductID As Integer Public Property ProductName As String Public Property Price As Decimal End Classrupesh gourRank #6,510 · 264 reputationPosted Feb 13, 2024, 12:10 AM EST
no i want to work also on repeater,
Please suggest
Amit MohantyRank #112 · 20K reputationPosted Feb 13, 2024, 12:45 AM EST
By using Repeater control:
Public Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Not IsPostBack Then BindRepeater() End If End Sub Private Sub BindRepeater() Dim connectionString As String = "Data Source=.;Initial Catalog=TestingDB;Integrated Security=SSPI;" Dim query As String = "SELECT ID, Name, Price FROM Products" Using connection As New SqlConnection(connectionString) Using command As New SqlCommand(query, connection) connection.Open() Using reader As SqlDataReader = command.ExecuteReader() ' Bind the data to the repeater Repeater1.DataSource = reader Repeater1.DataBind() End Using End Using End Using End Sub Protected Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick ' Rebind repeater every 2 seconds BindRepeater() End Sub End Classrupesh gourRank #6,510 · 264 reputationPosted Feb 13, 2024, 1:36 AM EST
i have an text box in repeater but after 2 sec value is restored, then how this issue will handled?
Amit MohantyRank #112 · 20K reputationPosted Feb 13, 2024, 3:00 AM EST
You can store the values of textboxes in ViewState or Session state, and then restore those values when rebinding the repeater.
rupesh gourRank #6,510 · 264 reputationPosted Feb 13, 2024, 4:29 AM EST
after click event popup for kyc which is closed after 2 sec , how to resolved.
Amit MohantyRank #112 · 20K reputationPosted Feb 13, 2024, 4:34 AM EST
Could you please share a minimal, reproducible code snippet, so we can better understand the problem?