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