[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get the values from ascx control to aspx page?

Posted on 2006-04-14
8
Medium Priority
?
388 Views
Last Modified: 2012-08-14
I'm using Microsoft Visual Studio 2005.  I'm trying get values from my user control (ascx) page to aspx (.aspx) page.  The values in the user control are the listbox controls, I would like to be able to loop thru the listbox from .aspx page to .ascx controls.

I saw some examples and try to follow the example that was posted, I got the error message of saying: "System.NullReferenceException: Object reference not set to an instance of an object."

What I have do wrong?

Here's my source code:
Declare:

Protected oProductListCtl As ProductListCtl

Dim cboSelProductList As ListBox
cboSelProductList = oProductListCtl.FindControl("cboSelectedProduct")
(it failed in here:System.NullReferenceException: Object reference not set to an instance of an object.)

For i = 0 To cboSelProductList.Items.Count - 1
       sSelValue = sSelValue & cboSelProductList.Items(i).Value & ","
Next

Your help will be greatly appreciated.
Annie
0
Comment
Question by:achen30
  • 4
  • 3
7 Comments
 

Author Comment

by:achen30
ID: 16455586
sorry I post in wrong topics. This should be in asp.net.
0
 
LVL 10

Accepted Solution

by:
jagadeesh_motamarri earned 750 total points
ID: 16455688
>>cboSelProductList = oProductListCtl.FindControl("cboSelectedProduct")
cboSelProductList = (ProductListCtl)oProductListCtl.FindControl("cboSelectedProduct")
...not sure..though
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:achen30
ID: 16456039
I find out other way to work around this problem.
Thanks,
All
0
 

Author Comment

by:achen30
ID: 16456105
This is the way that I got around with this by using Property get and set:

Public Property ProductSelected() As String
            Get
                Dim i As Integer
                m_ProductSelected = ""
                For i = 0 To Me.cboSelectedProduct.Items.Count - 1
                    m_ProductSelected = m_ProductSelected & cboSelectedProduct.Items(i).Value & ","
                Next
                Return m_ProductSelected
            End Get
            Set(ByVal Value As String)
                m_ProductSelected = Value
            End Set
        End Property

Thanks,
Annie
0
 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 16456118
u might want to post it in the cleanup area to get a refund...
0
 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 16456127
:)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month18 days, 17 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question