Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to add footer template dynamically in asp.net
    primarykey
    data
    text
    <p>I have created a gridview dynamically. There is template fields described in designing portion. All the columns were created thru code behind as follows. Its works fine. Here I can listed the pages for each rows. But I dont know how to implement the sum of pages in the footer template thru code behind. </p> <pre><code>TemplateField Pages = new TemplateField(); Pages.HeaderText = "Pages"; Pages.ItemTemplate = new GridViewTemplate_Pages(); gv1.Columns.Add(Pages); public class GridViewTemplate_Pages : ITemplate { void ITemplate.InstantiateIn(Control container) { Label PagesLabel = new Label(); PagesLabel.DataBinding += new EventHandler(this.PagesLabel_DataBinding); container.Controls.Add(PagesLabel); } void PagesLabel_DataBinding(object sender, EventArgs e) { Label lbl1 = (Label)sender; GridViewRow row = (GridViewRow)lbl1.NamingContainer; lbl1.Text = DataBinder.Eval(row.DataItem, "PagesReceived").ToString(); } } </code></pre> <p>Given ShowFooter="True" in aspx page and RowDataBound written separately. The following code works fine if I given footer template in aspx page but do not know how to get the result in programmatically. Please advice.</p> <pre><code> protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { int RowTotalPages = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "PagesReceived")); TotalPages = TotalPages + RowTotalPages; } if (e.Row.RowType == DataControlRowType.Footer) { Label m = (Label)e.Row.FindControl("gv1TotalPages"); m.Text = TotalPages.ToString(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload