Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
i have a gridview in which i m displaying text from a table, in my last column's footer template i want to import data on a label from another table.
Posted 27-Dec-12 0:12am
Comments
AshishChaudha at 27-Dec-12 5:44am
   
need more explaination!!what you have tried ??
a2ulthakur at 27-Dec-12 6:26am
   
i am using GridView1_RowDataBound and under this i am trying to get output in a label.
a2ulthakur at 27-Dec-12 6:29am
   
basically its a gridview which shows result of budget so i need to show data in label like total alloted, balance amount, and total expenditure, now this total is being imported from another table which has the data.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi,
 
On rowdatabound find footer template, in footer template find the required labels then assign values to the label.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

What is the issue then?
You need to try it by yourself. Follow the steps below(Search Google for other issues.):
Go to the RowDataBound event of GridView --> check for the footer item --> find the label control --> set the text of that label control(Put the conditions here if any).
 

--Amit
  Permalink  
Comments
a2ulthakur at 28-Dec-12 0:08am
   
@amit its like i have a gridview which shows budget information so my gridview is taking values from a table called monthly but in order to show the total allotted amount of the project i need to show it on label and this value should be corresponding to a value in a column from another table called project. This is what i am not able to figure out .. how to do this how to show the value from a cell of another table inside a gridview which uses another table as dataset
_Amy at 28-Dec-12 0:44am
   
Try this:

GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
Lable lbl1 =(Label)e.Row.FindControl("YourLabelTextToDisplay");
Lable lbl2 =(Label)e.Row.FindControl("YourLabelBasedOn");
//suppose another table is tbTest.
lbl1.Text = tbTest.AsEnumerable().Where(s => s.Field("MyCol") == lbl2.Text).Select(s => s.Field("MyCol")).First();
}
}
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

MSDN could help you!Just try it more and more!
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
if (e.Row.RowType == DataControlRowType.DataRow)
        {
            total = t1 + t2 + t3 + t4 + t5 + t6;
        }
        if (e.Row.RowType == DataControlRowType.Footer)
        {
            Label lblamount7 = (Label)e.Row.FindControl("glabel");
            lblamount7.Text = total.ToString();
        }
 
    }
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 245
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 Afzaal Ahmad Zeeshan 120
4 DamithSL 115
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 12 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100