我需要将字段(ComputerTag)绑定到文本字段。如何将字段绑定到文本框
此我的代码:
public void load()
{
//Intializing sql statement
string sqlStatement = "SELECT Computertag FROM Computer WHER
[email protected]";
SqlCommand comm = new SqlCommand();
comm.CommandText = sqlStatement;
int computerID = int.Parse(Request.QueryString["ComputerID"]);
//get database connection from Ideal_dataAccess class
SqlConnection connection = Ideal_DataAccess.getConnection();
comm.Connection = connection;
comm.Parameters.AddWithValue("@ComputerID", computerID);
try
{
connection.Open();
comm.ExecuteNonQuery();
//Bind the computer tag value to the txtBxCompTag Text box
txtBxCompTag.Text= string.Format("<%# Bind(\"{0}\") %>", "Computertag");
}
catch (Exception ex)
{
Utilities.LogError(ex);
throw ex;
}
finally
{
connection.Close();
}
}
但 “txtBxCompTag.Text =的String.Format(” <%#绑定(\ “{0} \”)%> “ ”Computertag“);”这行代码不会将该值绑定到文本框。我怎样才能将值分配给文本框?
感谢,作为一个新手乌尔xample帮了不少忙。 – Sas 2012-02-14 14:13:44