Click here to Skip to main content
16,016,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Comments
AshishChaudha 27-Dec-12 5:44am    
need more explaination!!what you have tried ??
a2ulthakur 27-Dec-12 6:26am    
i am using GridView1_RowDataBound and under this i am trying to get output in a label.
a2ulthakur 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.

Hi,

On rowdatabound find footer template, in footer template find the required labels then assign values to the label.
 
Share this answer
 
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
 
Share this answer
 
Comments
a2ulthakur 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 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<string>("MyCol") == lbl2.Text).Select(s => s.Field<string>("MyCol")).First();
}
}
MSDN could help you!Just try it more and more!
 
Share this answer
 
C#
 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();
        }

    }
 
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