TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bob Gatto
NA
44
8k
My password unmasking is working but not the way I want it to
Dec 1 2020 1:21 PM
I've masked a password column in a datagridview with this code:
private
void
dataGridView2_CellFormatting(
object
sender, DataGridViewCellFormattingEventArgs e)
{
if
(e.ColumnIndex == 2 && e.Value !=
null
){
if
(MouseButtons == MouseButtons.Left &&
e.ColumnIndex==2 && e.RowIndex == dataGridView2.CurrentCell.RowIndex)
{
int
idno = (
int
)dataGridView2.Rows[e.RowIndex].Cells[
"Id"
].Value;
SqlConnection c =
new
SqlConnection(ConStr);
string
query =
"select * from Passwords where Id = "
+
idno;DataTable Tbl =
new
DataTable();
using
(SqlDataAdapter da =
new
SqlDataAdapter(query, c))
{
c.Open();
da.Fill(Tbl);
c.Close();
}
c.Dispose();
dataGridView2.Rows[e.RowIndex].Cells[2].Value = Tbl.Rows[0][
"password"
].ToString();
}
else
e.Value =
new
String(
'*'
, e.Value.ToString().Length);
}
}
I want to hold down the left mouse button and have only that cell that the cursor is over be unmasked and then have it masked again as soon as I release the mouse button. I only want this happening when the cursor is over the password column (which is columnindex 2).
The problem I'm having is the password column unmasks even if the mouse is not in the password column.
How can I fix this?
Thanks for your help,
Bob Gatto
Reply
Answers (
2
)
post data to MVC Controller from view using Ajax.
Download only the new file from FTP server