Results 1 to 6 of 6

Thread: [RESOLVED] Hiding the tr in asp.net

  1. #1

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Resolved [RESOLVED] Hiding the tr in asp.net

    Good day all

    i have a strange issue here.

    i have a table row defined like this

    Code:
    		    <tr  id="tr6_3" runat="server" visible='<%# CheckVisible() %>' >
                            <td>
                            </td>
                            <td>
                                <strong>10.10 Introduction of a Project </strong>
                            </td>
                        </tr>
    and the Function defined on that server is like this

    Code:
    Public Function CheckVisible() As Boolean
               Dim sqlcout As New StringBuilder()
    
            sqlcout.Append("select Count(*) as [COUNT]")
            sqlcout.Append(" from mytable")
            sqlcout.Append(" where fieldid= '" + fieldid+ "'")
    
            Dim drcount As DataRow = clsFunctions.returnaRow(sqlcout.ToString())
            Dim Results As Boolean
            If (drcount Is Nothing = False) Then
                If (drcount("COUNT") = 0) Then
    
                    Results = False
                Else
                    Results = True
    
                End If
            End If
            Return Results
    
        End Function
    i have debuged this and it brings "0" but the Tr does not get hidden. i am i missing something here?

    thanks

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Hiding the tr in asp.net

    Hi.Having in mind that this will not work if you are calling it as a function somewhere,sometime inside your code,
    add this on page load.
    Code:
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            Page.DataBind()
        End Sub
    You can of course put that on, let's say a button click.
    Although i am not fond of messing markup with server side code.
    Last edited by sapator; Mar 10th, 2012 at 09:45 AM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  3. #3

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Re: Hiding the tr in asp.net

    Thanks for your reply

    i have resolved it by doing the Following

    Code:
     If (drcount Is Nothing = False) Then
                If (drcount("COUNT") = 0) Then
    
                    Results = "display : none;"
                Else
                    Results = "display : block;"
                End If
            End If
    and

    and on the markup i have something like this

    HTML Code:
    <tr style='<%= CheckVisible()%>'>

  4. #4
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: [RESOLVED] Hiding the tr in asp.net

    Hi.Since you have it run on the server you can change it whenever you want like this:
    Code:
     tr6_3.Style.Add("display", "none")
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  5. #5

    Thread Starter
    Fanatic Member vuyiswamb's Avatar
    Join Date
    Jan 2007
    Location
    South Africa
    Posts
    830

    Re: [RESOLVED] Hiding the tr in asp.net

    Yes
    Thanks

  6. #6
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: [RESOLVED] Hiding the tr in asp.net

    No problem
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width