0

Getting issue while exporting grid to excel is "control of type 'button' must be placed inside a form tag with runat=server + Sharepoint 2010"

  • I think you need to add more details to this question, it is a bit hard to understand what the problem is right now – Robert Lindgren Jun 11 '14 at 18:26
  • we want to export a grid view data to excel.In grid view we have button like "edit" , "delete" and link button.how can i export my grid to excel without columns which contain these buttons.i think due to these button i am getting error .Please suggest. – Jon Jun 12 '14 at 5:35
0

Maybe you need this buttons to have a runat="server" tag and for exporting, only take the text of each row and not the controls. Something like this:

 foreach (GridViewRow row in grid.Rows)
 {
                foreach (TableCell cell in row.Cells)
                {
                    String cellValue = HttpUtility.HtmlDecode(cell.Text);
                }
 }
  • foreach (GridViewRow row in grdSalesOrders.Rows) { table.Rows.Add(row); } table.RenderControl(htmlwriter); – Jon Jun 12 '14 at 9:28
  • this is my code and getting error on last line while render control. – Jon Jun 12 '14 at 9:29
  • suppose i have 6 column in grdSalesOrders and i want only number 3,5 in table row. how can i do it ?i want the row which i am going to ad in table not contain that column which giving me error . – Jon Jun 12 '14 at 9:33
  • you only want those column going into the excel, right? – Gwny Jun 12 '14 at 9:44
  • yes i want only column 3,5 .but how to add in table – Jon Jun 12 '14 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.