如何将asp dataview中的单个单元格格式化为“password”? [英] How can i format a single cell in asp dataview to "password"?

查看:54
本文介绍了如何将asp dataview中的单个单元格格式化为“password”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的一个页面上有一个显示用户信息的绑定DataView。

其中一行显示用户密码。



如何格式化该单元格的文本以显示*********而不是实际密码?



property_Datatype是密码 ,我需要格式化property_Value。

见下文:

I have a bound DataView on one of my pages that shows User information.
One of the rows Shows the User's Password.

How can I format that cell's text to show "*********" instead of the actual password?

The "property_Datatype" is "Password", and I need to format the "property_Value".
See below:

<asp:GridView runat="server" ID="gvProperties" AutoGenerateColumns="False" GridLines="None" CssClass="mGrid" OnRowDataBound="gvProperties_RowDataBound" ClientIDMode="Static"DataKeyNames="property_name, property_value, property_datatype, object_property_id, property_object_type, last_updated, source_name, trust_level, interest_level" ShowHeaderWhenEmpty="True">  
<RowStyle CssClass="rowHover1"></RowStyle>
<SelectedRowStyle backcolor="lightblue" BorderStyle="Outset" BorderWidth="1px"></SelectedRowStyle>  
<AlternatingRowStyle CssClass="rowHoverAlt1"></AlternatingRowStyle>
<Columns>
  <asp:BoundField DataField="property_name" HeaderText="Property" />
  <asp:BoundField DataField="property_value" HeaderText="Value" />
  <asp:BoundField DataField="property_datatype" Visible="false" />
  <asp:BoundField DataField="object_property_id" Visible="false" />
  <asp:BoundField DataField="property_object_type" Visible="false" />
  <asp:BoundField DataField="last_updated" Visible="false" />
  <asp:BoundField DataField="source_name" Visible="false" />
  <asp:BoundField DataField="trust_level" Visible="false" />
  <asp:BoundField DataField="interest_level" Visible="false" />
</Columns>
</asp:GridView>





我尝试过:



我试过谷歌,但所有的解决方案都展示了如何格式化整个专栏。我只需要格式化那个单元格。



What I have tried:

I have tried to Google it, but all the solutions show how to format the whole column. I just need to format that one cell.

推荐答案

没关系,我自己想出了这个!!!



以下是我的做法,以防万一其他人需要这样做。

你也可以用它来改变字体,粗体,背景颜色。



它基本上是在RowDataBound事件处理程序中完成的。



Never mind, I figured this out on my own!!!

Here is how I did it, just in case some one else needs to do this.
You can also use this to change the Font, Bold, Background colors.

It's basically done in the RowDataBound Event handler.

protected void gvProperties_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
{
    if ((e.Row.RowType == DataControlRowType.DataRow))
    {
        if(e.Row.Cells[0].Text == "Password")
        {
            e.Row.Cells[1].Text = new string('*', e.Row.Cells[1].Text.Length);
        }
     }
}


这篇关于如何将asp dataview中的单个单元格格式化为“password”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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