How to create column of type password in gridview?
Posted
by Preeti
on Stack Overflow
See other posts from Stack Overflow
or by Preeti
Published on 2010-04-29T08:31:17Z
Indexed on
2010/04/29
8:57 UTC
Read the original article
Hit count: 360
Hi,
I am creating an application in which user selects files and provides credentials to open that file. For that i have created three columns in a gridview.
User enters password in password column.
I want to display '*' in place of characters like we can create a textbox of password type.
I have tried this code on 'GridView_CellClick' event :
if (GridView.Columns[e.ColumnIndex].HeaderText == "Password")
{
txtPassword[e.RowIndex] = new TextBox();
txtPassword[e.RowIndex].Name = "txtPassword"+e.RowIndex;
txtPassword[e.RowIndex].PasswordChar = '*';
txtPassword[e.RowIndex].Visible = true;
txtPassword[e.RowIndex].TextChanged += new
if (GridView.CurrentCell.Value == null)
txtPassword[e.RowIndex].Text = "";
else
txtPassword[e.RowIndex].Text = GridView.CurrentCell.Value.ToString();
txtPassword[e.RowIndex].Location = GridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex + 1, false).Location;
txtPassword[e.RowIndex].Size = GridView.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex + 1, false).Size;
txtPassword[e.RowIndex].Visible = true;
txtPassword[e.RowIndex].Focus();
}
But in above solution characters are displayed.
How can i solve this problem???
© Stack Overflow or respective owner