Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从SQL Server数据库表中设置标签文本_C#_Asp.net_Sql Server - Fatal编程技术网

C# 如何从SQL Server数据库表中设置标签文本

C# 如何从SQL Server数据库表中设置标签文本,c#,asp.net,sql-server,C#,Asp.net,Sql Server,我需要动态地编写标签文本,而无需将其写入数据库表。我怎样才能得到它?所以我需要翻译成其他语言…谢谢 SQLDataReader中的.GetName方法可能通过获取列名称来解决您的问题。之后,可以设置标签文本 例如: var label = new List<Label>(); // store your labels in this list connection.Open(); command.CommandText = "Your Command"; DataReader =

我需要动态地编写标签文本,而无需将其写入数据库表。我怎样才能得到它?所以我需要翻译成其他语言…谢谢

SQLDataReader中的.GetName方法可能通过获取列名称来解决您的问题。之后,可以设置标签文本

例如:

var label = new List<Label>(); // store your labels in this list

connection.Open();
command.CommandText = "Your Command";
DataReader = command.ExecuteQuery();
if (DataReader.HasRows) {
    while(DataReader.Read()) {
         for(int i = 0; i < DataReader.FieldCount; i++) {

              // You can get the column names and set the label texts now
              // by making an array or list of labels like :
              label[i].Text = DataReader.GetName(i);                      

         }
    }
}
connection.Close();

到目前为止,您尝试过什么吗?例如label.text=obj_dt.string_value;那么如何翻译成其他语言呢?谢谢,但是如何翻译成其他语言呢?@Happy:看看ASP.Net中的本地化,这个链接是一个很好的起点@Happy:还有这个,