ASP.NET - Error al pasar datagrid que posee columna a excel

 
Vista:

Error al pasar datagrid que posee columna a excel

Publicado por Didi (18 intervenciones) el 24/09/2007 22:03:33
hola Sres.

Tengo problemas con el código de pasar un datagrid a un excel, creo que mi problema es porque mi datagrid contiene una columna tipo link, me pueden ayudar?

Este es el código que utilizo:

Dim strconexion As String
strconexion = "Server=localhost;Port=3306;Database=DATABASE_NCM;Uid=root;Pwd="";"
Dim objconexion As New MySqlConnection(strconexion)
Dim strMySQL As String
strMySQL = " select (COD_COUNTRY_NCM) as COUNTRY,(CUSTOMER_NCM) as CUSTOMER,(CITY_NCM) as City,(NAME_NETWORK_NCM) as NETWORK,(SITE_NAME_NCM) as SITE,(NODE_VENDOR) as N_VENDOR ,(NODE_NCM)as Node,(ACCEPTANCE_DATE_NCM) as DATE,(SW_CONTRACT_NAME) as SW_SUPPORT_CONTRACT,(SW_WARRANTY_STATUS_NCM) as SW_WARRANTY_STATUS,(SW_WARRANTY_START_DATE_NCM) as SW_WARRANTY_START_DATE,(SW_WARRANTY_END_DATE_NCM) as SW_WARRANTY_END_DATE,(HW_SERVICE_CONTRACT_NAME) as HW_SUPPORT_CONTRACT,(HW_WARRANTY_STATUS_NCM) as HW_WARRANTY_TYPE,(HW_WARRANTY_START_DATE_NCM) as HW_WARRANTY_START_DATE,(HW_WARRANTY_END_DATE_NCM) as HW_WARRANTY_END_DATE,(DEPLOYMENT_COMMITTED_NCM) as SW_UPDATE_COMMITMENT,(COMMENTS_NCM) as COMMENTS,(PLATFORM_TYPE_NCM) as PLATFORM_TYPE,(PLATFORM_VERSION_NCM) as PLATFORM_VERSION,(PLATFORM_CORRECTION_NCM) as PLATFORM_CORRECTION,(APPLICATION_TYPE_NCM) as APPLICATION_TYPE,(APPLICATION_VERSION_NCM) as APPLICATION_VERSION,(APPLICATION_CORRECTION_NCM)as APPLICATION_CORRECTION,(ADDITIONAL_CORRECTIONS_NCM)as ADDITIONAL_CORRECTIONS,(MAINTENANCE_LEVEL_NCM)as MAINTENANCE_LEVEL,(MAINTENANCE_LEVEL_END_DATE)as MAINTENANCE_LEVEL_END_DATE,(ID)as ID from tbl_network_ncm where COD_COUNTRY_NCM = '" & DropDownList4.Text & "' and CUSTOMER_NCM= '" & DropDownList1.Text & "' and NAME_NETWORK_NCM= '" & DropDownList5.Text & "'"
Dim objcommand As New MySqlCommand(strMySQL, objconexion)
Dim objadapter As New MySqlDataAdapter
objadapter.SelectCommand = objcommand
objconexion.Open()
Dim objds As New Data.DataSet
objadapter.Fill(objds, "Networks")
objconexion.Close()
DataGrid1.DataSource = objds
DataGrid1.DataBind()
'---
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "attachment;filename=Clientes.xls")
Response.Charset = ""
Me.EnableViewState = False
Dim oStringWriter As New System.IO.StringWriter()
Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
DataGrid1.RenderControl(oHtmlTextWriter)
Response.Write(oStringWriter.ToString())
Response.End()

El error que me arroja me señala esta línea :

DataGrid1.RenderControl(oHtmlTextWriter)

y dice esto:

Control 'DataGrid1_ctl02_ctl00' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Error al pasar datagrid que posee columna a ex

Publicado por Kwasir (1 intervención) el 27/09/2007 13:18:27
Debes sobrescribir el método VerifyRenderingInServerForm. Simplemente añade ésta sub:

Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar