如何将字段绑定到标签 [英] How Can I Bind Field To Label

查看:112
本文介绍了如何将字段绑定到标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

hi
如何将字段从表绑定到标签?

hi how can i bind field from table to label?

推荐答案

试试这个.. :)



try this..:)

//Put this code in Combobox selected index change event

      DataTable dt = new DataTable();
      using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionName"].ConnectionString))
      {
          using (SqlCommand cmd = new SqlCommand("select Mark from TableName where Name="+ ComboBox.SelectedValue, con))
          {
              con.Open();
              SqlDataAdapter da = new SqlDataAdapter(cmd);
              da.Fill(dt);

              lblMark.Text = Convert.ToString(dt.Rows["Mark"]);

              con.Close();
              con.Dispose();
              cmd.Dispose();
          }
      }


它的工作对我来说,但这个标签在我的Gridview里面



希望它也为你工作



< asp:label id =Name1runat =servertext =< ;%#DataBinder.Eval(Container.DataItem,column_name)%& gt;=xmlns:asp =#unknown>
Its work for me but this label was inside my Gridview

Hope its work for you also

<asp:label id="Name1" runat="server" text="<%#DataBinder.Eval(Container.DataItem, " column_name")%&gt;"="" xmlns:asp="#unknown">


这篇关于如何将字段绑定到标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆