Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
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.
Posted
Updated 12-Oct-11 7:54am
v2
Comments
Sergey Alexandrovich Kryukov 12-Oct-11 12:44pm    
Is is ASP.NET? Tag it!
--SA
supramur 12-Oct-11 13:48pm    
Yes it is ASP.NET.
Sergey Alexandrovich Kryukov 12-Oct-11 16:33pm    
I know. Thank you for tagging it. For you, its important that people knowledgeable in relevant fields could have noticed your post looking just at the title and the tags; that's why both should be accurate.
--SA

1 solution

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


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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900