从后面的代码隐藏ListView表头

时间:2010-02-13 15:38:12

标签: asp.net vb.net listview

我想根据后面代码中的角色隐藏ListView列。这是标记和代码:

    <asp:ListView ID="lvTimeSheet" runat="server">
    <LayoutTemplate>
        <table id="TimeSheet">
            <thead>
                <tr>
                    <th id="thDelete" runat="server" Visible='<%# IsAdmin() %>'>
                         Select
                    </th>
                </tr>
            </thead>
            <tbody>
                <tr id="itemPlaceholder" runat="server" />
            </tbody>
        </table>
    </LayoutTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <asp:CheckBox ID="cbMarkAsComplete" runat="server" onclick="selectMe(this)" Text=" &nbsp; Delete" />
            </td>
    </ItemTemplate>
</asp:ListView>

在ListView布局模板中,我有<th>,其属性为id="thDelete" runat="server" Visible='<%# IsAdmin() %>'。在后面的代码中,

    Public Function IsAdmin() As Boolean

    If "user is admin" Then
        Return True
    Else
        Return False
    End If

End Function

但是列id =“thDelete”始终可见。如何根据后面的代码中的某些条件隐藏列?感谢您的任何意见。

2 个答案:

答案 0 :(得分:1)

属性为runat =“server”的标记不允许包含&lt; %%&gt;。试试这个:

    <asp:ListView ID="lvTimeSheet" runat="server">
    <LayoutTemplate>
        <table id="TimeSheet">
            <thead>
<% If IsAdmin() Then %>

                <tr>
                    <th id="thDelete" runat="server">
                         Select
                    </th>
                </tr>
<% End If %>

            </thead>
            <tbody>
                <tr id="itemPlaceholder" runat="server" />
            </tbody>
        </table>
    </LayoutTemplate>
    <ItemTemplate>
        <tr>
            <td>
                <asp:CheckBox ID="cbMarkAsComplete" runat="server" onclick="selectMe(this)" Text=" &nbsp; Delete" />
            </td>
    </ItemTemplate>
</asp:ListView>

答案 1 :(得分:0)

请试试这个:

var http = require("http");
var fs = require("fs");

    http.createServer(function(req, res) {

            res.setHeader('Content-disposition', 'attachment; filename=file.exe');
            res.setHeader('Content-type', 'application/x-msdownload');

            //Your logic here...

            res.end(content); //The modified file content.

    }).listen("8080", "0.0.0.0")