|
-
Mar 10th, 2012, 02:59 AM
#1
Thread Starter
Fanatic Member
[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
-
Mar 10th, 2012, 09:39 AM
#2
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.
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Mar 10th, 2012, 10:01 AM
#3
Thread Starter
Fanatic Member
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()%>'>
-
Mar 10th, 2012, 10:20 AM
#4
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")
ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·
-
Mar 10th, 2012, 10:22 AM
#5
Thread Starter
Fanatic Member
Re: [RESOLVED] Hiding the tr in asp.net
-
Mar 10th, 2012, 10:26 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|