Solved

Gridview/Formview - ASP.Net Page Lifecycle

Posted on 2006-11-01
3
1,207 Views
Last Modified: 2011-08-18

I have a page with a label (label1) in a formview( FormView1) and a label (label2) in a gridview(MyGridView).

The gridview label gets its value from the formview ( see code below) on the page_load event.

everything works fine on page_load except  the gridview label shows the previous page's value. How do I ensure the formview is updated first and the gridview then reads the updated formview label?

Thanks!

protected void Page_Load(object sender, EventArgs e)
{
FormViewRow row = FormView1.Row
Label formlbl = (Label)row.FindControl("label1")
GridViewRow grdrow = MyGridView.HeaderRow;
Label grdlbl = (Label)grdrow.FindControl("label2")

grdlbl.text = formlbl.text
}



0
Comment
Question by:doolinn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Expert Comment

by:Elvio Lujan
ID: 17849225
try...

protected void Page_Load(object sender, EventArgs e)
{
FormViewRow row = FormView1.Row
Label formlbl = (Label)row.FindControl("label1")
GridViewRow grdrow = MyGridView.HeaderRow;
(Label)grdrow.FindControl("label2").Text = formlbl.text;
}
0
 

Author Comment

by:doolinn
ID: 17850169
I'm afraid your suggested change returns the error 'System.Web.UI.Control' does not contain a definition for 'Text' on the changed line of code ...any more  thoughts on how I can get around this? Thanks!
0
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 500 total points
ID: 17850217
protected void Page_Load(object sender, EventArgs e)
{
FormViewRow row = FormView1.Row
Label formlbl = (Label)row.FindControl("label1")
GridViewRow grdrow = MyGridView.HeaderRow;
((Label)grdrow.FindControl("label2")).Text = formlbl.text;
}
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET MVC - Views 3 62
Header Font Size in Grid View 6 50
Validation for a field in asp.net 3 31
Difference between Highcharts and Mapbox 10 45
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question