Click here to Skip to main content
15,512,456 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 coz i m not able to retain the values for Date.How can i achieve the task.Help me.
C#
protected void grdPBook_RowDataBound(object sender, GridViewRowEventArgs e)
{
   if (e.Row.RowType == DataControlRowType.DataRow)
   {
      strPreviousRowID = DataBinder.Eval(e.Row.Date).ToString()}
      grdPBook.ShowFooter = false;
   }
}

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-----
      }
   }
}
Posted
Updated 4-Jan-14 2:51am
v5
Comments
Nelek 4-Jan-14 6:38am    
Î have added the code block and adjusted the indexation.

On ther other hand... you were missing some opening and closing brackets in this snippet (I have added them), please check your code, if you are missing them there too, add them. Missing brackets can cause ignoring evaluations or some codes in the cascaded IF's
pwavell 4-Jan-14 7:50am    
The code is all good..just to tell what exactly i m doing i have written some part of code.i need a way to retain the value(here Date) that are required to generate dynamic rows..

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