【发布时间】:2016-08-27 08:38:58
【问题描述】:
我的数据库中的数据是加密的。当我在 gridview 上打印它时,它是这样的:
在我的标记上:
<asp:GridView ID="GridView1" SelectMethod="GetParents" ... >
<Columns>
<asp:TemplateField HeaderText="LastName" SortExpression="LastName">
<ItemTemplate>
<asp:Label Text='<%# GetDecrypted((string)Eval("LastName"))%>'
runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
在我的代码上:
protected string GetDecrypted(string Decrypt)
{
//returns a decrypted version
return ENCRYPTION.Decrypt(Decrypt);
}
这是我的选择方法
public IQueryable<Parent> GetParents()
{
InfantRecordContext db = new InfantRecordContext();
int id = int.Parse(Session["DoctorID"].ToString());
return db.Parent.Where(p => p.DoctorID == id);
}
问题是,当我对列进行排序时,它对加密数据而不是解密数据进行排序,有没有一种方法可以对我的 gridview 上显示的解密数据进行排序?
或者有什么方法可以在排序之前解密该字段?
【问题讨论】:
-
为什么不在绑定到 GridView 之前解密它?
-
您使用什么作为 gridview 的数据源?
-
嗨@mason,我更新了我的帖子,如果你能在将它绑定到 Gridview 之前发布你的解密想法,我将不胜感激。我知道如何使用全选返回,但我不知道如何逐个选择字段并首先解密它们。谢谢!
-
@DVK 你好!我更新了我的帖子并添加了我用于选择方法的部分谢谢!
-
我编辑了这个问题,以便更清楚地了解您具体需要做什么。
标签: c# asp.net sorting gridview encryption