[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Footer data GridView

Posted on 2013-05-12
3
Medium Priority
?
510 Views
Last Modified: 2013-05-13
I am looping through a GridView to obtain Row, footer and header data. I can check the status of the DataControlRowType and get the rows, but cannot seem to get the footer.

<asp:TemplateField HeaderText="Amount" FooterStyle-Font-Bold="True"  SortExpression="Amount">
                <ItemTemplate>
                  <asp:Label ID="lblAmount" runat="server" Text='<%# GetAmount(decimal.Parse(Eval("Amount").ToString()))%>'></asp:Label>
                </ItemTemplate>
                <FooterTemplate>
                  <asp:Label ID="lblTotalAmount" runat="server" Text='<%# GetTotalAmount().ToString()%>'></asp:Label>
                </FooterTemplate>
                    <FooterStyle Font-Bold="True" />
                </asp:TemplateField>


This fails in code behind:

 foreach (GridViewRow row in this.gridView.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {

if( row.RowType == DataControlRowType.Footer)
{
}                    
}
}

Open in new window

0
Comment
Question by:proginc
[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
3 Comments
 
LVL 8

Accepted Solution

by:
rpkhare earned 2000 total points
ID: 39159679
Not sure but are you trying to get the Footer row data?

In that case you can get Footer Row data as below:

 
       string CustomerName = string.Empty;
       GridViewRow row = GridView1.FooterRow; 
        CustomerName = ((TextBox)row.FindControl("txtCustomer")).Text;

Open in new window

0
 
LVL 1

Author Comment

by:proginc
ID: 39159994
Rows have a different control name from the footer, hence I need to confirm that I am reading the footer row before I use FindControl, how is this not working in my case. Header row detection does not work either.
0
 
LVL 12

Expert Comment

by:duttcom
ID: 39160238
rpkhare's suggestion goes straight to the footer row to find the control.

You don't need to loop through all of the rows to identify which one is the header row and which one is the footer row. There is only one header row and one footer row so you can access those rows specifically as rpkhare has suggested -

GridViewRow row = GridView1.FooterRow

Bear in mind also that header and footer rows cannot be data-bound.
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

656 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