| | |
convert string to object type
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Apr 2008
Posts: 114
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 |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net bc30451 beginner bottomasp.net browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class click commonfunctions compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datagridviewcheckbox datalist deadlock deployment development dgv dialog dropdownmenu dynamic edit embeddingactivexcontrol expose findcontrol flash flv formatdecimal forms formview gridview homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects order problem ratings rotatepage save search security serializesmo.table sessionvariables silverlight smartcard sql sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video virtualdirectory vista visual-studio visualstudio vs2008 web webarchitecture webdevelopemnt webdevelopment wizard xml youareanotmemberofthedebuggerusers





