Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Converting a string to an object property
Message
De
12/06/2008 15:29:35
 
 
À
12/06/2008 15:22:08
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01323589
Message ID:
01323592
Vues:
16
>OK, for some reason this is tough for me.
>
>I have a table in SQL Server that stores paramters and the control source of those parameters.
>
>For one row, the column name is ReportParmValue and it contains "GridView1.SelectedValue". This is represented in the code as
>
>Dim cRPV As String = dtResult.Rows(0).Item("ReportParmValue")
>
>cRPV will now contain "GridView1.SelectedValue".
>
>My problem is that I want the value of the form control GridView1.SelectedValue (which should be a string) and not the string "GridView1.SelectedValue".
>
>The VFP equivalent would be something like
>
>x = (cRPV) ..or.. x = EVALUATE(cRPV)
>
>Any ideas? Thanks.

There is no evaluate in .NET. But, the closest thing to achieve that would be to consider using reflection. This is what I use when it comes to things like that. I haven't used it specifically for that so far but to instantiate objects where the class name is stored in a field. So, it goes something like this:
        Dim loList As Framework.Framework.List
        Dim loParameter(0) As Object

        loParameter(0) = oProcess

        Try
            loClass = Type.GetType("NorthEasternGuide." + Trim(loRow("List1")))
            loList = Activator.CreateInstance(loClass, loParameter)
        Catch loError As Exception
            oProcess.ErrorSetup(loError)
            Return False
        End Try
loRow("List1") contains the class name. This comes from a field. I also pass a parameter. This is custom. But, this should give you an idea on what direction to look for to resolve that issue.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform