c# - Dynamicaly merging cells and hiding rows in gridview and exporting it to excel -


i m hiding columns while exporting griddata excel checking/unchecking checkboxes.the code have used follows

protected void btnpacklist_click(object sender, eventargs e) {     string printtype = "";     string vrnumber = "";     string userid = "";     foreach (gridviewrow row in gridview2.rows)     {         checkbox chkbxheader = gridview2.headerrow.findcontrol("chkbxheader") checkbox;         checkbox chkbxselect = row.findcontrol("chkbxselect") checkbox;         label vrno = row.findcontrol("vrno") label;         if (chkbxheader.checked == true)         {             printtype = "all";             userid = ddlcustomer.selectedvalue;         }         else if (chkbxselect.checked == true)         {             printtype = "selected";             if (vrnumber == "")             {                 vrnumber = "'" + vrno.text + "'";             }             else             {                 vrnumber = vrnumber + "," + "'" + vrno.text + "'";             }         }     }     if (printtype == "selected")     {         response.redirect("transactionreport.aspx?vrnumber=" + vrnumber + "&printtype=" + printtype);     }     else if (printtype == "all")     {         response.redirect("transactionreport.aspx?userid=" + userid + " &printtype=" + printtype);     }         response.redirect("testprint.aspx"); } 

i m dynamicaly merging first cell of gridview using following code in rowdatabound event of grid.

protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) {     if (e.row.rowtype == datacontrolrowtype.datarow)     {        datarowview drv = ((datarowview)e.row.dataitem);         if (previousname == drv["name"].tostring())         {              if (gridview1.rows[firstrow].cells[0].rowspan == 0)             {                  gridview1.rows[firstrow].cells[0].rowspan = 2;            }              else             {                 gridview1.rows[firstrow].cells[0].rowspan += 1;             }             e.row.cells.removeat(0);         }         else           {             e.row.verticalalign = verticalalign.middle;               previousname = drv["name"].tostring();              firstrow = e.row.rowindex;          }     }  } 

when remove rowdatabound code proper results in excel sheet if use row databound code additional cells adding , improper results in excel sheet.please me...i m stucked...

thanks in advance


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -