| | |
convert string to object type
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 115
Reputation:
Solved Threads: 6
Hi
I have a procedure that performs checks on controls in my page against rules set in a SQL table. It all works fine except that when im casting the control e.g.
and its a dropdownlist it of course fails.
Im trying to create a variable that gets populated from the table with the correct control type and then use this in the cast. i.e replace textbvox with my variable that could say either 'textbox' or 'dropdownlist'
but if i just put the string value variable in it gives error 'Type 'ControlType' is not defined'.
I wonderd if anyonme had any ideas
I have a procedure that performs checks on controls in my page against rules set in a SQL table. It all works fine except that when im casting the control e.g.
ASP.NET Syntax (Toggle Plain Text)
CType(Me.Page.FindControl(control1), TextBox).Text
and its a dropdownlist it of course fails.
Im trying to create a variable that gets populated from the table with the correct control type and then use this in the cast. i.e replace textbvox with my variable that could say either 'textbox' or 'dropdownlist'
but if i just put the string value variable in it gives error 'Type 'ControlType' is not defined'.
I wonderd if anyonme had any ideas
Please mark this post as 'Solved' if it has helped and fixed your issue.
•
•
Join Date: Jan 2009
Posts: 21
Reputation:
Solved Threads: 0
Use a condition before casting the control like this:
regards,
ASP.NET Syntax (Toggle Plain Text)
If TypeOf(Me.Page.FindControl(control1)) IS DropDownList Then CType(Me.Page.FindControl(control1), DropDownList).SelectedIndex = xyz End If
regards,
![]() |
Similar Threads
- Convert Object type to DataTime? (C#)
- converting a String obj to an istream obj (C++)
- Convert object of type string to a string (C++)
- Convert string variable into form object in VB6 (Visual Basic 4 / 5 / 6)
- convert string into object (Visual Basic 4 / 5 / 6)
- How to convert string to const char* in C (C++)
- Element is undefined in a Java object of type class [Ljava.lang.String; referenced as (ColdFusion)
Other Threads in the ASP.NET Forum
- Previous Thread: ASP.Net timer control
- Next Thread: need some information regarding ASP.Net Project
| Thread Tools | Search this Thread |
Tag cloud for ASP.NET
.net 2.0 activexcontrol advice ajax alltypeofvideos anathor application asp asp.net bc30451 bottomasp.net browser button c# c#gridviewcolumn checkbox click commonfunctions confirmationcodegeneration content courier css dataaccesslayer database datagridview datagridviewcheckbox datalist deadlock development dgv dropdownlist dynamically edit expose feedback fill flash form formatdecimal forms formview google grid gridview homeedition hosting iframe iis javascript jquery listbox login microsoft mono mouse mssql multistepregistration news numerical objects opera panelmasterpagebuttoncontrols parent project radio registration reportemail richtextbox rotatepage save schoolproject search security silverlight smartcard smoobjects software sql-server sqlserver2005 suse textbox tracking unauthorized validation vb.net video videos view virtualdirectory vista visualstudio web webapplications webdevelopemnt webprogramming webservice xml xsl youareanotmemberofthedebuggerusers





