Last post Aug 09, 2016 06:26 AM by Nan Yu
Aug 08, 2016 07:48 AM|Lexi85|LINK
<asp:Label ID="lblFilename" runat="server" Text='<%# getFileName(Eval("FName"))%>' />
I have this in my aspx code but gives an error while building application...says 'getFileName' is not declared it may be inaccessible due to its protection level
below is get filename vb.net code
Public Function getFileName(ByVal fileIn As String) As String
Dim fileOut As String = String.Empty
Dim filesIn() As String = fileIn.Split(".")
Select Case filesIn.Length
Case Is >= 2
fileOut = filesIn(1)
For I As Integer = 2 To filesIn.Length - 1
fileOut += "." & filesIn(I)
fileOut = filesIn(0)
Aug 08, 2016 08:20 AM|stmarti|LINK
You cannot call the instance methods of your code behind file in an aspx page. However you can convert getFileName to static (shared in vb) method. You can also move getFileName to a static utility class (best).
Aug 08, 2016 05:53 PM|paindaasp|LINK
If the Public Function getFileName resides in the CodeBehind file for your ASPX page, it should be found.
Aug 09, 2016 06:26 AM|Nan Yu|LINK
Hi Lexi85 ,
You could also the RowDataBound event of the gridview, and in there you can use e.Row.FindControl() to find your label (remember to cast it type label) and set the Text value as you wish.