密码文本框未显示动态绑定的值 [英] Password textbox didn't show value which one binded dynamically
本文介绍了密码文本框未显示动态绑定的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何将数据动态绑定到密码文本框中.
我只是将一个asp:table放入我的代码中,并通过代码生成两个文本框并绑定数据库中的值,但是由于该textmode = password属性,我无法将该值查看到我的文本框中,并且该文本框仍然为空白,所以我该怎么办?在我的文本框中获取价值.
C#代码如下
Hi i want to know that how to bind data dynamically into the password textbox.
I just put an asp:table into my code and generate two textboxes through code and bind the value from database but due to that textmode=password property i was not able to view that value into my textbox and the textbox remains blank so how can i get value into my textbox.
Code of c# as follows
try
{
SqlDataAdapter da = new SqlDataAdapter("select * from login", con);
DataSet ds = new DataSet();
con.Open();
da.Fill(ds, "login");
con.Close();
if (ds.Tables[0].Rows.Count > 0)
{
TableRow r = new TableRow();
r.BackColor = System.Drawing.Color.Blue;
r.ForeColor = System.Drawing.Color.White;
Table1.GridLines = GridLines.Both;
TableCell c = new TableCell();
Label l = new Label();
l.Text = "User Name";
c.Controls.Add(l);
r.Controls.Add(c);
Table1.Controls.Add(r);
TableCell c1 = new TableCell();
TextBox t = new TextBox();
t.Text = ds.Tables[0].Rows[0]["UName"].ToString();
c1.Controls.Add(t);
r.Controls.Add(c1);
Table1.Controls.Add(r);
TableRow r1 = new TableRow();
r1.BackColor = System.Drawing.Color.Blue;
r1.ForeColor = System.Drawing.Color.White;
Table1.GridLines = GridLines.Both;
TableCell c2 = new TableCell();
Label l1 = new Label();
l1.Text = "Password";
c2.Controls.Add(l1);
r1.Controls.Add(c2);
Table1.Controls.Add(r1);
TableCell c3 = new TableCell();
TextBox t2 = new TextBox();
t2.TextMode = TextBoxMode.Password;
t2.Text = ds.Tables[0].Rows[0]["Password"].ToString();
c3.Controls.Add(t2);
r1.Controls.Add(c3);
Table1.Controls.Add(r1);
}
else
{
}
}
catch (Exception Main)
{
lblMsg.Text = Main.Message.ToString();
}
推荐答案
ASP. NET密码文本框 [ ^ ]
这篇关于密码文本框未显示动态绑定的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文