Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
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();
        }
Posted
Updated 3-Nov-11 17:06pm
v4

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900