How do I get a handle to a gridview control on a page from within a Static Function?
I have:
Public Shared Function GetHidden(ByVal context As HttpContext) _
As String
'Return DateTime.Now.ToString()
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 & "' />"
Return HideString
End Function
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") & "' />"
codeaholic
Participant
1367 Points
707 Posts
Handle to a gridview in a substitution static function
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?
I have:
Public Shared Function GetHidden(ByVal context As HttpContext) _ As String 'Return DateTime.Now.ToString() 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 & "' />" Return HideString End FunctionThe 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:
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") & "' />"molly_c
Participant
1590 Points
401 Posts
Re: Handle to a gridview in a substitution static function
Dec 14, 2012 01:55 AM|LINK
Refering this link,
http://forums.asp.net/t/1727319.aspx/1
Molly
It's time to start living the life you are imagined.
codeaholic
Participant
1367 Points
707 Posts
Re: Handle to a gridview in a substitution static function
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.