Avatar of IUAATech
IUAATech

asked on 

how to populate a templatefield in gridview

Hello.

I need help with the following problem.
I have a gridview with two bound fields, numItems and itemPrice. I have an empty templatefield that has a label control. I need to display the result of numItems * itemPrice as Total using the label control. I have tried to do it in the RowDataBound event, but the FindControl method fails to find the control.

    protected void gvItems_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        Label itemTotal = (Label)e.Row.FindControl("lblItemTotal");
    }

What am I doing wrong here. I am using a SQLDataSource for the GridView and am open to returning the itemTotal in the SQL query if that's easier. numItems in an integer and itemPrice is smallmoney.

THanks.
ASP.NETC#

Avatar of undefined
Last Comment
IUAATech
ASKER CERTIFIED SOLUTION
Avatar of Pra4444
Pra4444
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of IUAATech
IUAATech

ASKER

perfect!!

Thank you.
ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo