Hi nedash,
Refer the below sample. You need to assign the Attributes["value"] after assigning the textbox value like in the below code.
HTML
<asp:TextBox ID="txtpass" runat="server" CssClass="txtramzD" TextMode="Password"></asp:TextBox>
C#
if (!this.IsPostBack)
{
string constr = ConfigurationManager.ConnectionStrings[1].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("SELECT TOP 1 * FROM Customers"))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
SqlDataReader rdr = cmd.ExecuteReader();
while (rdr.Read())
{
txtpass.Text = rdr["Country"].ToString();
txtpass.Attributes["value"] = txtpass.Text;
}
con.Close();
}
}
}
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
If Not Me.IsPostBack Then
Dim constr As String = ConfigurationManager.ConnectionStrings(1).ConnectionString
Using con As New SqlConnection(constr)
Using cmd As New SqlCommand("SELECT TOP 1 * FROM Customers")
cmd.CommandType = CommandType.Text
cmd.Connection = con
con.Open()
Dim rdr As SqlDataReader = cmd.ExecuteReader()
While rdr.Read()
txtpass.Text = rdr("Country").ToString()
txtpass.Attributes("value") = txtpass.Text
End While
con.Close()
End Using
End Using
End If
End Sub