I am trying to use one function to handle a SelectedIndexChanged 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.pagesize.
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 SystemNullException 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(ControlFromName("dgToH1"), DataGrid)
dg.DataSource = dv
dg.DataBind()
Private Function ControlFromName(ByVal name As String) As WebControl
Dim o As Object
o = Me.GetType().GetField(name, Reflection.BindingFlags.Public Or _
Reflection.BindingFlags.NonPublic Or _
Reflection.BindingFlags.Instance Or _
Reflection.BindingFlags.IgnoreCase).GetValue(Me)
Return (CType(o, WebControl))
End Function
--
Message posted via http://www.dotnetmonster.com