У меня есть эта c# программа для форм, и я хочу получить значение текстовой метки по некоторым причинам, может кто-нибудь помочь?
Я уже пробовал это
String name = myLabel.Text
Имя строки = myLabel.Text.ToString
, но не будет отображаться.
conn = dbHelper.getConnect();
conn.Open();
cmd = new SqlCommand("select custID from customer where name = '" + custNameLbl /*this is where i want to get the value*/ + "'", conn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
custIDStorage = Convert.ToInt32(dr[0].ToString()); //this is an int
namename.Text = custIDStorage.ToString(); //this is a label
}
cmd.Dispose();
dr.Close();
conn.Close();