P
Paul Bromley
I am trying to get somewhere with user controls and have come up against an
obstacle with using relative paths.
I have a dataset in my user control, and have tried to enter the path with
the following:-
dsResultsTable.ReadXml(Application.StartupPath &
"\Textfiles\ResultsTable.xml")
It does not like this, as it takes the application path to be C:\Program
Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe.
I have also tried to send the path into the user control as a variable,
using a property - it does not like this either, as it is again looking for
the path above as I try and place the control on my page..
Can anyone point me to a possible solution and explain where I am going
wrong. Why cannot I pass the path in as a property??
ResultsPathXML is being sent to the user control as
(Application.StartupPath & "\Textfiles\ResultsTable.xml"), and I have this
in the Load of my form that is using the control.
Finally are there any good - ? web-based resources to help me with user
controls, using the Usercontrol class, as I think that this will avoid me
doing a lot of repetitive coding in my applications.
Many thanks - Paul Bromley
Public Class ctlSendResultsEMIS
Inherits System.Windows.Forms.UserControl
Private sLabFilter As String
Private sLabResult As String
Private sLabCode As String
Private dsResultsTable As New DataSet()
Private dvResultsTable As New Data.DataView()
Private sResultsPath As String '= (Application.StartupPath &
"\Textfiles\ResultsTable.xml")
Property ResultsPathXML() As String
Get ' Retrieves the value of the private variable.
Return sResultsPath
End Get ' Stores the selected value in the private variable txtTrialText
Set(ByVal Value As String)
sResultsPath = Value
End Set
End Property
Later in the code:-
Private Sub ctlSendResultsEMIS_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dsResultsTable.ReadXml(sResultsPath)
dvResultsTable = dsResultsTable.Tables(0).DefaultView '.DefaultView
GridResults.DataSource = dvResultsTable
End Sub
obstacle with using relative paths.
I have a dataset in my user control, and have tried to enter the path with
the following:-
dsResultsTable.ReadXml(Application.StartupPath &
"\Textfiles\ResultsTable.xml")
It does not like this, as it takes the application path to be C:\Program
Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe.
I have also tried to send the path into the user control as a variable,
using a property - it does not like this either, as it is again looking for
the path above as I try and place the control on my page..
Can anyone point me to a possible solution and explain where I am going
wrong. Why cannot I pass the path in as a property??
ResultsPathXML is being sent to the user control as
(Application.StartupPath & "\Textfiles\ResultsTable.xml"), and I have this
in the Load of my form that is using the control.
Finally are there any good - ? web-based resources to help me with user
controls, using the Usercontrol class, as I think that this will avoid me
doing a lot of repetitive coding in my applications.
Many thanks - Paul Bromley
Public Class ctlSendResultsEMIS
Inherits System.Windows.Forms.UserControl
Private sLabFilter As String
Private sLabResult As String
Private sLabCode As String
Private dsResultsTable As New DataSet()
Private dvResultsTable As New Data.DataView()
Private sResultsPath As String '= (Application.StartupPath &
"\Textfiles\ResultsTable.xml")
Property ResultsPathXML() As String
Get ' Retrieves the value of the private variable.
Return sResultsPath
End Get ' Stores the selected value in the private variable txtTrialText
Set(ByVal Value As String)
sResultsPath = Value
End Set
End Property
Later in the code:-
Private Sub ctlSendResultsEMIS_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load
dsResultsTable.ReadXml(sResultsPath)
dvResultsTable = dsResultsTable.Tables(0).DefaultView '.DefaultView
GridResults.DataSource = dvResultsTable
End Sub