473,785 Members | 2,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use Existing Object by String Name

I am trying to use one function to handle a SelectedIndexCh anged event for 5 radio button groups that correspond to 5 populated Datagrids. The radio buttons have a choice of 5,10 25 for a datagrid.pagesi ze.

I am having trouble trying to find a way to pass the name of the existing datagrid object to the function and to have it assign its the appropriate datasource, pagesize and rebind.

I found a post with this ControlFromName Function and have tried to use it but it fails with s SystemNullExcep tion in the function. Please bear with my lack of knowledge on this, reflection and some of this heavy programming is new to me. Here i my code blurb and the function as I have it. I did change it to use WebControl instead of Control since this is on as aspx page.

Thanks for any help. Damon
Dim dv As DataView
Dim dg As DataGrid
dg = CType(ControlFr omName("dgToH1" ), DataGrid)
dg.DataSource = dv
dg.DataBind()

Private Function ControlFromName (ByVal name As String) As WebControl
Dim o As Object
o = Me.GetType().Ge tField(name, Reflection.Bind ingFlags.Public Or _
Reflection.Bind ingFlags.NonPub lic Or _
Reflection.Bind ingFlags.Instan ce Or _
Reflection.Bind ingFlags.Ignore Case).GetValue( Me)

Return (CType(o, WebControl))
End Function

--
Message posted via http://www.dotnetmonster.com
Nov 21 '05 #1
2 1167
hi!

i've just answered this one on the french ng.. the answer is still in my
clipboard :O)
http://groups.google.com/groups?thre...TNGP10.phx.gbl

--
Best Regards
Yanick
"Damon Gravning via DotNetMonster.c om" <fo***@DotNetMo nster.com> a écrit
dans le message de
news:ab******** *************** *******@DotNetM onster.com...
I am trying to use one function to handle a SelectedIndexCh anged event for 5 radio button groups that correspond to 5 populated Datagrids. The radio
buttons have a choice of 5,10 25 for a datagrid.pagesi ze.
I am having trouble trying to find a way to pass the name of the existing datagrid object to the function and to have it assign its the appropriate
datasource, pagesize and rebind.
I found a post with this ControlFromName Function and have tried to use it but it fails with s SystemNullExcep tion in the function. Please bear with
my lack of knowledge on this, reflection and some of this heavy programming
is new to me. Here i my code blurb and the function as I have it. I did
change it to use WebControl instead of Control since this is on as aspx
page.
Thanks for any help. Damon
Dim dv As DataView
Dim dg As DataGrid
dg = CType(ControlFr omName("dgToH1" ), DataGrid)
dg.DataSource = dv
dg.DataBind()

Private Function ControlFromName (ByVal name As String) As WebControl
Dim o As Object
o = Me.GetType().Ge tField(name, Reflection.Bind ingFlags.Public Or _
Reflection.Bind ingFlags.NonPub lic Or _
Reflection.Bind ingFlags.Instan ce Or _
Reflection.Bind ingFlags.Ignore Case).GetValue( Me)

Return (CType(o, WebControl))
End Function

--
Message posted via http://www.dotnetmonster.com

Nov 21 '05 #2
Could you just pass the control as an object to the Function;

Function myfunction(mygr id as DataGrid)
mygrid.property ...
End Function

"Zoury" wrote:
hi!

i've just answered this one on the french ng.. the answer is still in my
clipboard :O)
http://groups.google.com/groups?thre...TNGP10.phx.gbl

--
Best Regards
Yanick
"Damon Gravning via DotNetMonster.c om" <fo***@DotNetMo nster.com> a écrit
dans le message de
news:ab******** *************** *******@DotNetM onster.com...
I am trying to use one function to handle a SelectedIndexCh anged event for

5 radio button groups that correspond to 5 populated Datagrids. The radio
buttons have a choice of 5,10 25 for a datagrid.pagesi ze.

I am having trouble trying to find a way to pass the name of the existing

datagrid object to the function and to have it assign its the appropriate
datasource, pagesize and rebind.

I found a post with this ControlFromName Function and have tried to use it

but it fails with s SystemNullExcep tion in the function. Please bear with
my lack of knowledge on this, reflection and some of this heavy programming
is new to me. Here i my code blurb and the function as I have it. I did
change it to use WebControl instead of Control since this is on as aspx
page.

Thanks for any help. Damon
Dim dv As DataView
Dim dg As DataGrid
dg = CType(ControlFr omName("dgToH1" ), DataGrid)
dg.DataSource = dv
dg.DataBind()

Private Function ControlFromName (ByVal name As String) As WebControl
Dim o As Object
o = Me.GetType().Ge tField(name, Reflection.Bind ingFlags.Public Or _
Reflection.Bind ingFlags.NonPub lic Or _
Reflection.Bind ingFlags.Instan ce Or _
Reflection.Bind ingFlags.Ignore Case).GetValue( Me)

Return (CType(o, WebControl))
End Function

--
Message posted via http://www.dotnetmonster.com


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

25
7646
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
1
2415
by: Richard Holliingsworth | last post by:
Hello: The group has new 'standards' for online forms and I need to change the 'style' of my existing forms (A2002). Can I do this? I can't find a way using the GUI or the properties. Thanks, Richard H
1
36830
by: Brent Jenny | last post by:
I have an existing xml file taht looks like this. <?xml version="1.0" encoding="utf-8" ?> <Aircraft> <WCOJOItemType type="AircraftType" > <WCJOItemCode>03</WCJOItemCode> <WCJOItemDescription>B737-700</WCJOItemDescription> </WCOJOItemType> </Aircraft> I want to be able to add nodes to the doc using C#. I have tried the
5
2267
by: Matthew | last post by:
I have a nice little Sub that saves data in a class "mySettings" to an XML file. I call it like so: Dim mySettings As mySettings = New mySettings mySettings.value1 = "someText" mySettings.value2 = "otherText" xmlSave("C:\folder\file.xml", mySettings) Here is the sub: Public Shared Sub xmlSave(ByVal path As String, ByVal config As
0
1214
by: Al Fatykhov | last post by:
Using MABLE logic engine with existing .NET applications. MABLE web services provide an interface to MABLE business objects and logic. Let us review some technical details of the MABLE web services. · MABLE utilizes SOAP 1.2 protocol. · MABLE uses AXIS 1.4 as a web service transport. · MABLE support state-full conversations by implementing a conversation session.
5
3095
by: Mukesh | last post by:
Hi i want to use AJAX.net in my Existing Application I have already installed the ajax .net ..net 3.0 and using VS 2005 in the old application i have added a new web form then script manager and then update panel and some control in it to test it. When i run the programme ir does not work . imean ajax does not works
13
2604
by: =?Utf-8?B?UGV0ZXI=?= | last post by:
I want to create a new column in a datatable from two existing columns. I have no problem to create the new column using the datatable.columns.add method. The problem is the value of the new column may become system.dbnull since one of the two existing columns may have system.dbnull. How can I fix it so the new column will get the value of the other column even the other column is system.dbnull?
1
1736
by: Allen | last post by:
I need a way to add a method to an existing instance, but be as close as possible to normal instance methods. Using 'new' module or such code as 'def addfunc(...): def helper(...) .. setattr(...)' causes a cyclic reference which requires using 'gc.collect' to release the object. Also 'new' is deprecated. I also made a helper that uses weakref, but the problem is when the object is gone, existing instance method object would not work: ...
0
10357
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10163
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10104
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7510
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.