courchjo
asked on
I am unable to manipulate a User Control's Label controls from the host ASPX page. I am trying to create N-number of user controls and add it to my Host.aspx page. Any help woul be greatly appreciate
I am unable to manipulate a User Control's Label controls from the host ASPX page. I am trying to create N-number of user controls and add it to my Host.aspx page. Any help woul be greatly appreciated.
My ASPX page looks like this.
Host.aspx.vb-------------- ---------- ---------- --------->
Public Class Host
Public Sub Service_Info()
Dim objRLL As New ReplacementLostLicense
While objReader.Read()
Dim objUCTL As New myUserControl
If IsDBNull(objReader.Item("S erviceType CD")) = False And objReader.Item("ServiceTyp eCD") = "DOCREP" Then
objRLL.DateMailed = objReader.Item("MailDt")
objRLL.ReturnToDDS_Dt = objReader.Item("ReturnToDD S")
End If
End If
objServiceCtl.DisplayData( Nothing, Nothing, objRLL)
service_status_Holder.Cont rols.Add(o bjServiceC tl)
End While
End Sub
ENd Class
And MyUserControl.aspx.vb looks like this ------------------------->
Public Class myUserControl
Public Sub DisplayData(ByVal objMVR3 As MVRData, ByVal objMVR7 As MVRData, ByVal objRLL As ReplacementLostLicense)
If IsNothing(objRLL) = False Then
lblRLLDateMailed.Text = objRLL.DateMailed
lblRLLReturntoDDSDate.Text = objRLL.ReturnToDDS_Dt
End If
End Class
My ASPX page looks like this.
Host.aspx.vb--------------
Public Class Host
Public Sub Service_Info()
Dim objRLL As New ReplacementLostLicense
While objReader.Read()
Dim objUCTL As New myUserControl
If IsDBNull(objReader.Item("S
objRLL.DateMailed = objReader.Item("MailDt")
objRLL.ReturnToDDS_Dt = objReader.Item("ReturnToDD
End If
End If
objServiceCtl.DisplayData(
service_status_Holder.Cont
End While
End Sub
ENd Class
And MyUserControl.aspx.vb looks like this ------------------------->
Public Class myUserControl
Public Sub DisplayData(ByVal objMVR3 As MVRData, ByVal objMVR7 As MVRData, ByVal objRLL As ReplacementLostLicense)
If IsNothing(objRLL) = False Then
lblRLLDateMailed.Text = objRLL.DateMailed
lblRLLReturntoDDSDate.Text
End If
End Class
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Please follow my instructions above. It should fix it.
Ted
Ted
ASKER
Thanks for the reply. I did make the changes. But the problem still persists.
Public Class Host
Public Sub Service_Info()
Dim objRLL As New ReplacementLostLicense
While objReader.Read()
Dim objUCTL As New myUserControl
If IsDBNull(objReader.Item("S erviceType CD")) = False And objReader.Item("ServiceTyp eCD") = "DOCREP" Then
objRLL.DateMailed = objReader.Item("MailDt")
objRLL.ReturnToDDS_Dt = objReader.Item("ReturnToDD S")
End If
End If
objUCTL.DisplayData(Nothin g, Nothing, objRLL)
service_status_Holder.Cont rols.Add(o bjUCTL)
End While
End Sub
ENd Class
And MyUserControl.aspx.vb looks like this ------------------------->
Public Class myUserControl
Public Sub DisplayData(ByVal objMVR3 As MVRData, ByVal objMVR7 As MVRData, ByVal objRLL As ReplacementLostLicense)
If IsNothing(objRLL) = False Then
lblRLLDateMailed.Text = objRLL.DateMailed
lblRLLReturntoDDSDate.Text = objRLL.ReturnToDDS_Dt
End If
End Class
Public Class Host
Public Sub Service_Info()
Dim objRLL As New ReplacementLostLicense
While objReader.Read()
Dim objUCTL As New myUserControl
If IsDBNull(objReader.Item("S
objRLL.DateMailed = objReader.Item("MailDt")
objRLL.ReturnToDDS_Dt = objReader.Item("ReturnToDD
End If
End If
objUCTL.DisplayData(Nothin
service_status_Holder.Cont
End While
End Sub
ENd Class
And MyUserControl.aspx.vb looks like this ------------------------->
Public Class myUserControl
Public Sub DisplayData(ByVal objMVR3 As MVRData, ByVal objMVR7 As MVRData, ByVal objRLL As ReplacementLostLicense)
If IsNothing(objRLL) = False Then
lblRLLDateMailed.Text = objRLL.DateMailed
lblRLLReturntoDDSDate.Text
End If
End Class
Do the following:
Dim objUCTL As myUserControl
While objReader.Read()
If IsDBNull(objReader.Item("S erviceType CD")) = False And objReader.Item("ServiceTyp eCD") = "DOCREP" Then
objRLL.DateMailed = objReader.Item("MailDt")
objRLL.ReturnToDDS_Dt = objReader.Item("ReturnToDD S")
objUCTL = New myUserControl
objUCTL.DisplayData(Nothin g, Nothing, objRLL)
service_status_Holder.Cont rols.Add(o bjUCTL)
End If
End If
End While
Again, I would personally make it so that you have properties for your User control....
Dim objUCTL As myUserControl
While objReader.Read()
If IsDBNull(objReader.Item("S
objRLL.DateMailed = objReader.Item("MailDt")
objRLL.ReturnToDDS_Dt = objReader.Item("ReturnToDD
objUCTL = New myUserControl
objUCTL.DisplayData(Nothin
service_status_Holder.Cont
End If
End If
End While
Again, I would personally make it so that you have properties for your User control....
courchjo,
May I ask why you gave a "C" for this answer? I provided exactly what was needed including the necessary code to fix the problem.
Ted
May I ask why you gave a "C" for this answer? I provided exactly what was needed including the necessary code to fix the problem.
Ted
ASKER
Hi Ted,
It was some thing to do with the way I was passing my data to my control. And wasn’t an issue with the way I had instantiated the objects. I redid my control all over again and coded it from start. And the new control seems to be working fine.
And I took a bit of a different approach. I used the dataset and used the filter property within a loop rather than using the datareader to group by a specific column.
Anyway I really appreciate the tips you gave. And I did use properties like you suggested. And I am using my friends account. I am new to the forum. So wasn’t so sure about the points system.
Thanks
Jay
It was some thing to do with the way I was passing my data to my control. And wasn’t an issue with the way I had instantiated the objects. I redid my control all over again and coded it from start. And the new control seems to be working fine.
And I took a bit of a different approach. I used the dataset and used the filter property within a loop rather than using the datareader to group by a specific column.
Anyway I really appreciate the tips you gave. And I did use properties like you suggested. And I am using my friends account. I am new to the forum. So wasn’t so sure about the points system.
Thanks
Jay
Jay,
Thanks for responding. A couple notes:
1. Your code as originally posted would not work that way (at least past the first user control added to your placer).
2. As many use already posted answers to find answers to new questions (somebody may run into the same problem), it is always best to post the final answer for future reference
3. It's always best to put "Accepted Answer" next to the actual accepted answer.
4. You can always request a points refund in the event that your question was not answered, but of course, sometimes it's better just to give the points if you have received legitimate help that you used in reaching your solution.
Past that, hope you enjoy EE and good luck with your app.
Ted
Thanks for responding. A couple notes:
1. Your code as originally posted would not work that way (at least past the first user control added to your placer).
2. As many use already posted answers to find answers to new questions (somebody may run into the same problem), it is always best to post the final answer for future reference
3. It's always best to put "Accepted Answer" next to the actual accepted answer.
4. You can always request a points refund in the event that your question was not answered, but of course, sometimes it's better just to give the points if you have received legitimate help that you used in reaching your solution.
Past that, hope you enjoy EE and good luck with your app.
Ted
ASKER
What I am basically trying to do is create multiple instances of my user control within a while loop for each record in my DataReader. And pass in some data to my usercontrol as objects where that data is picked up and displayed in various Labels and Text boxes (No other complex controls used).
The error i am getting is on my UserControl page where I am trying set a value for my label.
It says "Object reference not set to an instance of an object." It even shows breaks with the same msg when you did a
Response.write(objRLL.Date
Host.aspx.vb--------------
Public Class Host
Public Sub Service_Info()
Dim objRLL As New ReplacementLostLicense
While objReader.Read()
Dim objUCTL As New myUserControl
If IsDBNull(objReader.Item("S
objRLL.DateMailed = objReader.Item("MailDt")
objRLL.ReturnToDDS_Dt = objReader.Item("ReturnToDD
End If
End If
objServiceCtl.DisplayData(
service_status_Holder.Cont
End While
End Sub
ENd Class
And MyUserControl.aspx.vb looks like this ------------------------->
Public Class myUserControl
Public Sub DisplayData(ByVal objMVR3 As MVRData, ByVal objMVR7 As MVRData, ByVal objRLL As ReplacementLostLicense)
If IsNothing(objRLL) = False Then
lblRLLDateMailed.Text = objRLL.DateMailed
lblRLLReturntoDDSDate.Text
End If
End Class