简体   繁体   English

如何在C#的网格视图中添加密码字段

[英]How to add password field in Grid View in c#

I want to create password field in Data Grid view in WinForm c# .NET. 我想在WinForm c#.NET的“数据网格”视图中创建密码字段。

How should i proceed? 我该怎么办?

If it's for creating a password and you must do it in the grid, just use plain text and clear it out once you create the account. 如果是用于创建密码的,而您必须在网格中进行设置,则只需使用纯文本并将其清除即可。

If you're building an app where a customer service rep builds an account for a user, either send the user a password you generate or use some default password for your company (I would only use this with internal-use-only software). 如果您要构建一个客户服务代表为用户建立帐户的应用程序,请向该用户发送您生成的密码,或者为公司使用一些默认密码(我只会将此密码与内部专用软件一起使用)。 Then force them to change it on the user's first login. 然后,强迫他们在用户的首次登录时对其进行更改。

I can only assume you don't want the ability of your grid users to view passwords. 我只能假设您不希望网格用户查看密码。 If indeed that is the case, don't do it!!! 如果确实如此, 请不要这样做!!!

Try the following code. 请尝试以下代码。 It may helpful to you. 它可能对您有帮助。

protected void GridView1_PreRender1(object sender, EventArgs e)
{
  foreach (GridViewRow row in GridView1.Rows)
  {
    string pwd = new string('*', row.Cells[2].Text.Length);
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM