473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Get Data from Repeater Control

jcas1411
Okay, I have found a suggested C# solution that syntatically ported to VB.NET seemed to look right however getting a Null pointer exception when i try to get data from the control..
Expand|Select|Wrap|Line Numbers
  1. Dim details As New objFilingDetails
  2. Dim item As RepeaterItem
  3.  
  4. For Each item In Repeater1.Items
  5.         'the repeater contains datarow views, each row 3 textboxes, 1 label
  6.  
  7.        Dim dtrow As Data.DataRowView = CType(item.DataItem, Data.DataRowView)
  8.  
  9. 'gets to here....mouse over in debug shows item.DataItem is Nothing
  10. 'however does show two items in Repeater1.Items
  11.  
  12.             details.Description = (CType(dtrow.Item("txtbx_Documents"), TextBox)).Text
  13.             details.FAA_Advance = Decimal.FromOACurrency((CType(dtrow.Item("txtbx_FAAFee"), TextBox)).Text)
  14.             details.Aero_Fee = Decimal.FromOACurrency((CType(dtrow.Item("txtbx_AeroFee"), TextBox)).Text)
  15.             details.FAA_Number = (CType(dtrow.Item("lbl_FAANo"), Label)).Text
  16.  
  17.             objFiling.Details.Add(details)
  18.  
  19. Next
  20.  
Using a user control as basically 1 label 1 multiline textbox and 2 textboxes
wrote a ItemBound function in the forms codebehind and a setData in the code behind for the control...
Expand|Select|Wrap|Line Numbers
  1.  Private Sub Repeater1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles Repeater1.ItemDataBound
  2.         If (e.Item.ItemType = ListItemType.Item) Then
  3.             CType(e.Item.FindControl("filing"), _
  4.                filingControl).SetData(CType(e.Item.DataItem, _
  5.                Data.DataRowView), False)
  6.         End If
  7.         If (e.Item.ItemType = ListItemType.AlternatingItem) Then
  8.             CType(e.Item.FindControl("filing"), _
  9.                filingControl).SetData(CType(e.Item.DataItem, _
  10.                Data.DataRowView), True)
  11.         End If
  12.  
  13.     End Sub
  14.  
  15.  
  16.  Public Sub SetData(ByVal dr As Data.DataRowView, ByVal IsAlternating As Boolean)
  17.  
  18.         Me.lbl_FAANo.Text = dr("FAA_Number")
  19.         Me.txtbx_Documents.Text = dr("Description")
  20.         Me.txtbx_FAAFee.Text = FormatCurrency(dr("FAA_Advance"), 2)
  21.         Me.txtbx_AeroFee.Text = FormatCurrency(dr("Aero_Fee"), 2)
  22.  
  23.         If IsAlternating Then
  24.             Panel1.BackColor = Drawing.Color.LightGoldenrodYellow
  25.         End If
  26.  
  27.  
  28.     End Sub
  29.  

.................sets great............just can't seem to figure out how to get the data back from the textboxes (user edits) or label without this Null Pointer Exception
Mar 13 '08 #1
1 2241
Sweet, figured out my own problem after a little sleep. Basically my repeater didn't contain a datarowview object, it contained a UserControl that contained the datarowview object.... so my solution, add a getData() function in my user control and return the object it contains. In the codebehind for the form find user control and assign it to an object...workes and is clean.

Expand|Select|Wrap|Line Numbers
  1.   Function GetData() As objFilingDetails
  2.         Dim adetail As New objFilingDetails
  3.         adetail.FAA_Number = Me.lbl_FAANo.Text
  4.         adetail.Description = Me.txtbx_Documents.Text
  5.         adetail.FAA_Advance = Convert.ToDecimal(Me.txtbx_FAAFee.Text.Trim("(", "$", ")"))
  6.         adetail.Aero_Fee = Convert.ToDecimal(Me.txtbx_AeroFee.Text.Trim("(", "$", ")"))
  7.  
  8.         Return adetail
  9.     End Function
  10.  
  11. 'and in the codebehind
  12.      Dim details As New objFilingDetails
  13.         Dim item As RepeaterItem
  14.         For Each item In Repeater1.Items
  15.  
  16.             details = CType(item.FindControl("filing"), filingControl).GetData()
  17.             objFiling.Details.Add(details)
  18.  
  19.         Next
  20.  
  21.  
Mar 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David Bartosik - MS MVP | last post by:
I am wanting to display my data in columns horizontally across the page rather than vertically down the page to avoid scrolling. in other words rather than have column 1 column 2 I want...
2
by: John Holmes | last post by:
I am using radioButton controls in a data repeater and would like to incorporate the 'key' field into the 'id' attribute of the radioButton controls and name them something like: 'rad' + '<%#...
2
by: Steve | last post by:
Hi All I am trying to find a way of displaying data in a datatable in such a way that ALL rows (only about 5 - 10) are editable and are updated from a single button press. I thought the best way...
1
by: Dot net work | last post by:
Hello. I have an interesting data binding scenario: I have a repeater control. It repeats a typical custom web user control. I also have a collection object, and each collection element...
8
by: darrel | last post by:
*sigh*...I've asked this before, but have long forgotten the answer. In the past, I'd often use repeater controls, bind data to it, and then reference the data fields from within the repeater: ...
1
by: Greg Cyrus | last post by:
Hi, i have created a function to open a Databse by OLEDB and fill it into a System.Data.DataSet-Objekt by oleDBAdapter.Fill-Mehtod.. Now I want to assign this DataSet to a normal...
0
by: news_server.nc.rr.com | last post by:
How do i perform a databind on a web user control within a repeater or rather how can I access the datasource that is already bound? I have a web user control that displays a table of values (the...
7
by: charliewest | last post by:
Hello - I'm using a Repeater control to render information in a very customized grid-like table. The Repeater control is binded to a DataSet with several records of information. Within the...
1
by: coolego1 | last post by:
Hello, I am new to ASP.net programming. I know a bit about ASP, but not so much the new .NET framework. I have been playing with the data controls that are available, but I have not figured out...
3
by: Emma Middlebrook | last post by:
Hi there, I've been trying to implement a repeater control in an ASP.NET 2 page but I can't seem to get the layout exactly how I want and I'm not sure if it's something that I am doing wrong or...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.