在Gridview中将密码显示为*或其他符号 [英] Display Password as * or other symbol in Gridview

查看:109
本文介绍了在Gridview中将密码显示为*或其他符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用网格,其中我在网格中使用了客户信息.因此存在uname,密码,手机,地址字段.

密码来自数据库.

而且我还想这样做,当加载网格时,密码不是显示为字符或字符串,而是显示为*或其他符号.

我为此使用模板字段.

单击网格的编辑按钮时,密码仍为*或其他符号.

因此,请在加载网格时为我提供帮助,密码显示为Symbol.

谢谢和问候...
MItesh

Hello to all,

i am using the grid in which i use the customer information in grid. so there is uname,password,mobile,address filed.

password is came from database.

and i also want to do that the password is not display as character or string but display as * or other symbol when grid is loaded.

i use template field for that.

when click on edit button of grid the password remains as * or other symbol .

so, please help me when grid is load the password is display as Symbol.

Thanks and Regards...
MItesh

推荐答案

请重新考虑一下.
这意味着您将密码以纯文本格式存储在数据库中,这是一个非常愚蠢的主意.
请哈希您的密码!看看以下内容:密码存储:操作方法. [ ^ ]

你不看新闻吗?索尼?领英Match.Com?
Please, rethink this.
It means you are storing the password in straight text in your database, which is a spectacularly stupid idea.
Please, hash your passwords! Have a look at this: Password Storage: How to do it.[^]

Do you not watch the news? Sony? LinkedIn? Match.Com?


boundField 为例:

首先,设置DataField 属性:DataField=password

其次,定义处理GridViewPreRender 事件的函数:
Take boundField for example:

First, set the DataField property: DataField="password"

Second, define the function to process PreRender event of GridView:
protected void GridView1_PreRender(object sender, EventArgs e)
  {
        foreach (GridViewRow row in GridView1.Rows)
        {
            string pwd = new string('*', row.Cells[3].Text.Length);
            row.Cells[3].Text = pwd;
        }
  }


参考: GridView中的密码类型列 [


Ref.: Password Type Column in GridView[^]


这篇关于在Gridview中将密码显示为*或其他符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆