Click here to Skip to main content
15,922,166 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a gridview in which i have created dynamic rows in row created event as shown in below code.when i print the grid the print dialog opens and after closing the dialog the dynamically generated columns of grid disappers and the grid gets messed up.

C#
string strPreviousRowID = string.Empty;
       // To keep track the Index of Group Total
       int intSubTotalIndex = 1;
       // To temporarily store Sub Total
       double dblSubTotalAmount = 0;
       double dblGrandTotalAmount = 0;
       double robal = 0;
       double totAmt = 0;


C#
protected void grdPBook_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
      strPreviousRowID = DataBinder.Eval(e.Row.DataItem,"Date").ToString()}
      grdPBook.ShowFooter = false;
   }
}


C#
protected void grdPBook_RowCreated(object sender, GridViewRowEventArgs e)
{
   bool IsSubTotalRowNeedToAdd = false;
   bool IsGrandTotalRowNeedtoAdd = false;
   if (ddlSummary.SelectedValue == "0")
   {
      if ((strPreviousRowID != string.Empty)(DataBinder.Eval(e.Row.DataItem,"Date") != null))
      {
         if (strPreviousRowID != DataBinder.Eval(e.Row.DataItem, "Date").ToString())
         {
            if (ddlSummary.SelectedValue == "0")
            {
               IsSubTotalRowNeedToAdd = true;
            }
         }
      }
      if (IsSubTotalRowNeedToAdd)
      {
         // ---code for adding dynamic subtotal row-----
      }
   }
}

Please help me....
Posted
Updated 23-Feb-14 19:12pm
v3

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