如何将窗体视图标签值获取到formview外部的标签 [英] How to get the form view label value to the label outside the formview

查看:74
本文介绍了如何将窗体视图标签值获取到formview外部的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我正在尝试将formview标签的值放入formview之外的标签中.formview绑定到数据库.我正在尝试使用类似这样的内容:
< b> MatchScore.Text =((Label)FormView2.FindControl("MatchScoreValue")).Text;</b>
其中MatchScore是外部标签的ID,而MatchScoreValue是formview内部的标签的ID.我尝试将代码放入FormView的dataBound事件中,但仍然无法正常工作.每当formview2更改时,MatchScore的值都必须更改.

我正在开发一个Web应用程序,并使用C#作为背后的代码.
你能帮我吗?

谢谢.

Hi All,
I am trying to get the value of the formview label into the label outside the formview.The formview is bound to the database. i am trying to use something like this:
<b>MatchScore.Text = ((Label)FormView2.FindControl("MatchScoreValue")).Text;</b>
where MatchScore is the ID of the label outside and the MatchScoreValue is the ID of the label inside the formview.I tried putting the code in the dataBound event of the FormView but still not working. The value of the MatchScore has to change whenever the formview2 changes.

I am developing a web application and using C# for code behind.
Can you please help me?

Thanks.

推荐答案

在数据绑定事件中,下面的代码应该可以正常工作


It should be working fine with the below code in databound event


protected void FormView2_DataBound(object sender, EventArgs e)
{
  if (Page.IsPostBack)
  {
    this.MatchScore.Text = ((Label)FormView2.FindControl("MatchScoreValue")).Text;
  }
}


这篇关于如何将窗体视图标签值获取到formview外部的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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