Export to excel file from ASP.NET GridView with embedded dropdownlist.

Posted on 2006-06-05
Last Modified: 2012-05-05

I am trying to export to excel from an ASP.NET GridView. I have a dropdownlist embedded in the gridview. When I make the DropDownList invisible in my aspx page the export works.  I have reviewed Expert Exchange Q_21055376.html. I am trying to implement the ClearControls routine so that I can have a visible dropdownlist except during the export process. I did a cut & paste and converted the C# code to VB.NET
    ' Converted from C# to VB .NET using CSharpToVBConverter(1.2).
    ' Developed by: Kamal Patel (

This is the converted code.

  Private Sub ClearControls(ByVal control As Control)
        Dim i As Integer
        For i = control.Controls.Count - 1 To 0 Step i - 1
        If TypeOf Not (control Is TableCell) Then                                  '  <----------##    !!
            'If Not (control Is TableCell) Then

            If Not control.GetType().GetProperty("SelectedItem") Is Nothing Then
                Dim literal As LiteralControl = New LiteralControl()
                    literal.Text = CType(control.GetType().GetProperty("SelectedItem").GetValue(control, Nothing), String)
                End Try
                Dim literal As LiteralControl = New LiteralControl()
                literal.Text = CType(control.GetType().GetProperty("Text").GetValue(control, Nothing), String)
            End If
        End If
    End Sub

 I am getting the following error message on "TableCell". "TableCell" is a type and cannot be used as an expression. What is the proper VB conversion?
Question by:RonTrull
    1 Comment
    LVL 17

    Accepted Solution

           If Not control.GetType() = new TableCell.GetType() Then

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now