0

我有一个列表视图,我在其中绑定数据库中的数据。我有一个加密列,我们在保存到数据库时对其进行了加密。现在我想显示它的解密值。但我不知道在绑定列表时如何将该值传递给解密方法。我的html代码如下:

<asp:ListView ID="lsttest" runat="server" ItemPlaceholderID="trData" OnItemDataBound="lstRegOrg_ItemDataBound">
                            <LayoutTemplate>
                                <table cellspacing="0" border="0">
                                    <tr class="hdrRowColor1">
                                        <td width="35px" align="left">
                                            &nbsp;S.No
                                        </td>
                                        <td width="175px" align="left">
                                            <asp:LinkButton ID="lnkName" runat="server" CommandArgument="p.FirstName" OnClick="lnk_Sort">Name</asp:LinkButton>
                                            <asp:Image ID="img_lnkName" Visible="false" runat="server" />
                                        </td>
                                        <td width="175px" align="left">
                                            <asp:LinkButton ID="lnk_UserName" runat="server" CommandArgument="p.UserName" OnClick="lnk_Sort">User Name</asp:LinkButton>
                                            <asp:Image ID="img_lnk_UserName" Visible="false" runat="server" />
                                        </td>
                                        <td width="175px" align="left">
                                            <asp:LinkButton ID="lnkEmail" runat="server" CommandArgument="p.EmailAddress" OnClick="lnk_Sort">Email</asp:LinkButton>
                                            <asp:Image ID="img_lnkEmail" Visible="false" runat="server" />
                                        </td>
                                        <td width="120px" align="left">
                                            <asp:LinkButton ID="lnkRoleName" runat="server" CommandArgument="tblroles.RoleName"
                                                OnClick="lnk_Sort">Role</asp:LinkButton>
                                            <asp:Image ID="img_lnkRoleName" Visible="false" runat="server" />
                                        </td>
                                        <td width="150px" align="left">
                                            <asp:LinkButton ID="lnk_CreatedBy" runat="server" CommandArgument="u.firstName" OnClick="lnk_Sort">Created By</asp:LinkButton>
                                            <asp:Image ID="img_lnk_CreatedBy" Visible="false" runat="server" />
                                        </td>
                                        <td width="120px" align="left">
                                            <asp:LinkButton ID="lnkCreatedDate" runat="server" CommandArgument="p.CreatedDate"
                                                OnClick="lnk_Sort">Created Date</asp:LinkButton>
                                            <asp:Image ID="img_lnkCreatedDate" Visible="false" runat="server" />
                                        </td>
                                        <td width="150px" align="left">
                                            <asp:LinkButton ID="lnk_LastModifiedBy" runat="server" CommandArgument="u.firstName"
                                                OnClick="lnk_Sort">Last Modified By</asp:LinkButton>
                                            <asp:Image ID="img_lnk_LastModifiedBy" Visible="false" runat="server" />
                                        </td>
                                        <td width="125px" align="left">
                                            <asp:LinkButton ID="lnk_LastModifiedDate" runat="server" CommandArgument="p.CreatedDate"
                                                OnClick="lnk_Sort">Last Modified On</asp:LinkButton>
                                            <asp:Image ID="img_lnk_LastModifiedDate" Visible="false" runat="server" />
                                        </td>
                                        <td align="center" width="60px">
                                            <asp:LinkButton ID="lnkIsActive" runat="server" CommandArgument="p.IsActive" OnClick="lnk_Sort">IsActive</asp:LinkButton>
                                            <asp:Image ID="img_lnkIsActive" Visible="false" runat="server" />
                                        </td>

                                        <td align="center" width="50px" style="border-right: 1px solid #6398cc">
                                            Actions
                                        </td>
                                    </tr>
                                    <tr id="trData" runat="server">
                                    </tr>
                                </table>
                            </LayoutTemplate>
                            <ItemTemplate>
                                <tr class='<%# Convert.ToBoolean(Container.DataItemIndex % 2) ? "EvenRowColor" : "OddRowColor" %>'>
                                    <td align="left" valign="middle">
                                        &nbsp;<%# Container.DataItemIndex+1 %>.
                                    </td>
                                    <td align="left">
                                        <asp:Label ID="lblFullName" runat="server" Text='<%# Eval("Name")%>'></asp:Label>
                                    </td>
                                    <td align="left">
                                        <asp:Label ID="Label1" runat="server" Text='<%= CCMMUtility.Decryptdata(Eval("UserName")) %>' />
                                       <%-- <asp:Label ID="Label1" runat="server" Text='<%# Eval("UserName")%>' />--%>
                                    </td>
                                    <td align="left">
                                        <asp:Label ID="lblEmail" runat="server" Text='<%# Eval("EmailAddress")%>'></asp:Label>
                                    </td>
                                    <td align="left">
                                        <asp:Label ID="lblRole" runat="server" Text='<%# Eval("RoleName") %>'></asp:Label>
                                    </td>
                                    <td align="left">
                                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("CreatedBy") %>'></asp:Label>
                                    </td>
                                    <td align="left">
                                        &nbsp;<%# Convert.ToDateTime(Eval("CreatedDate")).ToString("MMM, dd yyyy") %>
                                    </td>
                                    <td align="left">
                                        <asp:Label ID="Label3" runat="server" Text='<%# Eval("ModifiedBy") %>'></asp:Label>
                                    </td>
                                    <td align="left">
                                        &nbsp;<%# Convert.ToDateTime(Eval("ModifyDate")).ToString("MMM, dd yyyy")%>
                                    </td>
                                    <td align="center">
                                        <asp:Label ID="lblName" runat="server" Style="display: none;" Text='<%# Eval("Name")%>'></asp:Label>
                                        <asp:Label ID="lbl_Status" runat="server" Style="display: none;" Text='<%# Eval("IsActive")%>'></asp:Label>
                                        <asp:ImageButton ID="imgbtnStatus" runat="server" CommandArgument='<%# Eval("id") %>'
                                            OnClick="imgbtnStatus_Onclick" />
                                    </td>

                                    <td align="center" class="last">
                                        <asp:ImageButton ID="imgbtnEdit" runat="server" ImageUrl="~/App_Themes/ThemeNew/Images/edit.png"
                                            ToolTip="Edit Details" CommandArgument='<%# Eval("Id") %>' OnClick="imgbtnEdit_OnClick" />

                                    </td>
                                </tr>
                            </ItemTemplate>
                        </asp:ListView>

我想为列用户名这样做。请帮我。

4

1 回答 1

2

你应该做

Text='<%# CCMMUtility.Decryptdata(Eval("UserName")) %>'

代替

Text='<%= CCMMUtility.Decryptdata(Eval("UserName")) %>'

实际上#是用来做数据绑定的,=是用来通过一些代码块来实现简单的字面量类型输出的,所以Eval()这是一个数据绑定的方法,里面不会有任何作用=

于 2012-08-30T13:49:03.927 回答