In a aspx page I have table as container and tds have different Repeaters in it.
在aspx页面中,我将表作为容器,tds中有不同的Repeater。
I know table is not a databound control but was wondering there may be a way to use data from dt to control visibility of a tr or any other html control ?
我知道table不是数据绑定控件但是想知道可能有办法使用dt中的数据来控制tr或任何其他html控件的可见性?
I just tried Page.Databind() but it was not successful and there was an error "Table is not a data bound control"
我只是尝试了Page.Databind(),但它没有成功,并且出现错误“表不是数据绑定控件”
Please guide.
请指导。
Thanks
谢谢
2 个解决方案
#1
2
You should use DISPLAY property to ensure that a blank space is not left by the row that is hidden instead of the VISIBLE property.
您应该使用DISPLAY属性来确保隐藏的行不会留下空白而不是VISIBLE属性。
With out knowing or seeing your code block for a a sible gle its difficult to second guess but if your using "Show" or Hide" as the swutches to decide wether to show or hide a row.........
在不知道或看到你的代码块的情况下,如果你使用“显示”或“隐藏”作为旋转来决定显示或隐藏一行.........
maybe your code should read as follows.....
也许你的代码应该如下所示......
<tr <%=GetDisplayStatus('switch') %>>
where switch is either "show" or "hide" and your SERVERSIDE function to get the display status should be as follows..
其中switch是“show”或“hide”,你的SERVERSIDE函数获取显示状态应如下所示。
Function GetDisplayStatus(SwitchState as String) as String
If SwitchState = "show" then
return " style=" & chr(34) & "display: block;" & chr(34)
ElseIf SwitchState = "hide" Then
return " style=" & chr(34) & "display: none;" & chr(34)
Else
' no action otherwise
return ""
End If
End Function
Please let me know if that works for you.
如果这对你有用,请告诉我。
#2
0
When working with ASP.Net, it's important to know which properties are processed by the server and which are html. When you use a <%#
tag, the value in your expression is written directly to the web server's response stream. It's too late at this point to assign to a server property. Visible is a server property.
使用ASP.Net时,了解服务器处理哪些属性以及哪些属性是html非常重要。使用<%#标记时,表达式中的值将直接写入Web服务器的响应流。此时分配给服务器属性为时已晚。 Visible是服务器属性。
#1
2
You should use DISPLAY property to ensure that a blank space is not left by the row that is hidden instead of the VISIBLE property.
您应该使用DISPLAY属性来确保隐藏的行不会留下空白而不是VISIBLE属性。
With out knowing or seeing your code block for a a sible gle its difficult to second guess but if your using "Show" or Hide" as the swutches to decide wether to show or hide a row.........
在不知道或看到你的代码块的情况下,如果你使用“显示”或“隐藏”作为旋转来决定显示或隐藏一行.........
maybe your code should read as follows.....
也许你的代码应该如下所示......
<tr <%=GetDisplayStatus('switch') %>>
where switch is either "show" or "hide" and your SERVERSIDE function to get the display status should be as follows..
其中switch是“show”或“hide”,你的SERVERSIDE函数获取显示状态应如下所示。
Function GetDisplayStatus(SwitchState as String) as String
If SwitchState = "show" then
return " style=" & chr(34) & "display: block;" & chr(34)
ElseIf SwitchState = "hide" Then
return " style=" & chr(34) & "display: none;" & chr(34)
Else
' no action otherwise
return ""
End If
End Function
Please let me know if that works for you.
如果这对你有用,请告诉我。
#2
0
When working with ASP.Net, it's important to know which properties are processed by the server and which are html. When you use a <%#
tag, the value in your expression is written directly to the web server's response stream. It's too late at this point to assign to a server property. Visible is a server property.
使用ASP.Net时,了解服务器处理哪些属性以及哪些属性是html非常重要。使用<%#标记时,表达式中的值将直接写入Web服务器的响应流。此时分配给服务器属性为时已晚。 Visible是服务器属性。