Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 14, 2012 02:49 PM by codeaholic
Dec 06, 2012 10:56 PM|LINK
How do I get a handle to a gridview control on a page from within a Static Function?
Public Shared Function GetHidden(ByVal context As HttpContext) _
Dim HideString As String
'Add Hidden Variables
Dim MyGrandTotal As Label = GridView2.FooterRow.FindControl("MyGrandTotal")
HideString = "<input type='hidden' name='x_invoice_num value='" & Session("orderid") & "' />"
HideString = HideString & "<br>" & "<input type='hidden' name='x_amount value='" & MyGrandTotal.Text.ToString & "' />"
The problem with this is that Gridview2 is undefined in the static member, so is the session.
I tried doing this but it didn't help:
'DefaultSPC is the code Behind Page Class
Dim MyPageClass As New DefaultSPC
Dim RefSession As HttpSessionState = HttpContext.Current.Session
Dim MyGrandTotal As Label = MyPageClass.GridView2.FooterRow.FindControl("MyGrandTotal")
HideString = "<input type='hidden' name='x_invoice_num value='" & RefSession("orderid") & "' />"
Dec 14, 2012 01:55 AM|LINK
Refering this link,
Dec 14, 2012 02:49 PM|LINK
Thanks that would not work for what I needed to do. I had to go a different way.