troubleshooting Question

How do I repopulate and rebind a Repeater with a different data source after a Postback?

Avatar of klm555
klm555 asked on
.NET ProgrammingVisual Basic.NETASP.NET
3 Comments1 Solution1430 ViewsLast Modified:
I have a repeater that initallly retrieve values from a database and the data source is based on the relevant fields names of the query created.  The fields in the repeater are populated with one or more fields from the datbase as shown on the ItemDataBound event

                Dim t As New TextBox
                t = e.Item.FindControl("EmployeeID")
                t.text = e.Item.DataItem("ID")
                t = e.Item.FindControl("EmployeeName")
                t.text = e.Item.DataItem("Surname") + " " + e.Item.DataItem("FirstName")

On a postback, I want to update the repeater, without accessing the database and utilising the existing data in the repeater.  I have created a DataTable, one for each of the controls in the repeater which then loops through each of the rows and rebinds to the repeater.

       Dim aTable As New System.Data.DataTable
        With aTable
            .Columns.Add("EmployeeID")
            .Columns.Add("EmployeeName")
        End With

The issue comes on the ItemDataBound event, when the repeater is rebound, where the data source is now different as the field names to the data source are now different.

The only way I believe to solve this issue to determine the data source that populates the repeater and to handle the data source approriately within the ItemDataBound event...

How do I identifiy the data source so I can handle the temDataBound correctly so the data source is repopulated using the datatable?
ASKER CERTIFIED SOLUTION
klm555

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros