How to create column of type password in gridview?
- by Preeti
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???