Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Gridview/Formview - ASP.Net Page Lifecycle

Posted on 2006-11-01
3
Medium Priority
?
1,221 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 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

670 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