Gridview export to Excel issue?

Can someone please help me to understand why AccessionA and AccessionB columns from this data grid do not export with the rest of the columns?

TIA,
Andrew

 SS
Protected Sub btnExportCSV_Click(ByVal sender As Object, ByVal e As EventArgs)
        Response.Clear()
        Response.Buffer = True
        Response.AddHeader("content-disposition", "attachment;filename=PlantssDNAExport.csv")
        Response.Charset = ""
        Response.ContentType = "application/text"

        GridView1.AllowPaging = False
        GridView1.DataBind()

        Dim sb As New StringBuilder()
        For k As Integer = 3 To GridView1.Columns.Count - 1
            'add separator
            sb.Append(GridView1.Columns(k).HeaderText + ","c)
        Next
        'append new line
        sb.Append(vbCr & vbLf)
        For i As Integer = 0 To GridView1.Rows.Count - 1
            For k As Integer = 3 To GridView1.Columns.Count - 1

                Dim strVal = GridView1.Rows(i).Cells(k).Text
                If String.IsNullOrWhiteSpace(strVal) Or String.Equals(strVal, " ") Then
                    GridView1.Rows(i).Cells(k).Text = ""
                Else
                End If

                'add separator
                sb.Append(GridView1.Rows(i).Cells(k).Text + ","c)
            Next
            'append new line
            sb.Append(vbCr & vbLf)
        Next
        Response.Output.Write(sb.ToString())
        Response.Flush()
        Response.End()
    End Sub

End Class

Open in new window

<%@ Page Title="Plant ssDNA Virus Database" Language="VB" MasterPageFile="Site.Master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
    <style type="text/css">
        .style1
        {
            color: #009900;
        }
    </style>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">

    <asp:SqlDataSource ID="SqlDSALL" runat="server" 
    ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
    DeleteCommand="DELETE FROM [PlantssDNA] WHERE [VID] = @original_VID" 
    InsertCommand="INSERT INTO [PlantssDNA] ([Family], [SubFamily], [Genus], [SubGenus], [Species], [Isolate], [Abbreviation], [AccessionA], [GIA] [NCA], [AccessionB], [GIB], [NCB], [Geography], [Year2007A], [Year2007B], [Year2008A], [Year2008B], [Year2009A], [Year2009B], [Year2010A], [Year2010B], [Year2011A], [Year2011B]) VALUES (@Family, @SubFamily, @Genus, @SubGenus, @Species, @Isolate, @Abbreviation, @AccessionA, @GIA, @NCA, @AccessionB, @GIB, @NCB, @Geography, @Year2007A, @Year2007B, @Year2008A, @Year2008B, @Year2009A, @Year2009B, @Year2010A, @Year2010B, @Year2011A, @Year2011B)" 
    OldValuesParameterFormatString="original_{0}" 
    SelectCommand="SELECT * FROM [PlantssDNA] ORDER BY [Family], [Genus], [Species]" 
    UpdateCommand="UPDATE [PlantssDNA] SET [Family] = @Family, [SubFamily] = @SubFamily, [Genus] = @Genus, [SubGenus] = @SubGenus, [Species] = @Species, [Isolate] = @Isolate, [Abbreviation] = @Abbreviation, [AccessionA] = @AccessionA, [GIA] = @GIA, [NCA] = @NCA, [AccessionB] = @AccessionB, [GIB] = @GIB, [NCB] = @NCB, [Geography] = @Geography, [Year2007A] = @Year2007A, [Year2007B] = @Year2007B, [Year2008A] = @Year2008A, [Year2008B] = @Year2008B, [Year2009A] = @Year2009A, [Year2009B] = @Year2009B, [Year2010A] = @Year2010A, [Year2010B] = @Year2010B, [Year2011A] = @Year2011A, [Year2011B] = @Year2011B WHERE [VID] = @original_VID">
    <DeleteParameters>
        <asp:Parameter Name="original_VID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="Family" Type="String" />
        <asp:Parameter Name="SubFamily" Type="String" />
        <asp:Parameter Name="Genus" Type="String" />
        <asp:Parameter Name="SubGenus" Type="String" />
        <asp:Parameter Name="Species" Type="String" />
        <asp:Parameter Name="Isolate" Type="String" />
        <asp:Parameter Name="Abbreviation" Type="String" />
        <asp:Parameter Name="AccessionA" Type="String" />
        <asp:Parameter Name="GIA" Type="String" />
        <asp:Parameter Name="NCA" Type="String" />
        <asp:Parameter Name="AccessionB" Type="String" />
        <asp:Parameter Name="GIB" Type="String" />
        <asp:Parameter Name="NCB" Type="String" />
        <asp:Parameter Name="Geography" Type="String" />
        <asp:Parameter Name="Year2007A" Type="String" />
        <asp:Parameter Name="Year2007B" Type="String" />
        <asp:Parameter Name="Year2008A" Type="String" />
        <asp:Parameter Name="Year2008B" Type="String" />
        <asp:Parameter Name="Year2009A" Type="String" />
        <asp:Parameter Name="Year2009B" Type="String" />
        <asp:Parameter Name="Year2010A" Type="String" />
        <asp:Parameter Name="Year2010B" Type="String" />
        <asp:Parameter Name="Year2011A" Type="String" />
        <asp:Parameter Name="Year2011B" Type="String" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="Family" Type="String" />
        <asp:Parameter Name="SubFamily" Type="String" />
        <asp:Parameter Name="Genus" Type="String" />
        <asp:Parameter Name="SubGenus" Type="String" />
        <asp:Parameter Name="Species" Type="String" />
        <asp:Parameter Name="Isolate" Type="String" />
        <asp:Parameter Name="Abbreviation" Type="String" />
        <asp:Parameter Name="AccessionA" Type="String" />
        <asp:Parameter Name="GIA" Type="String" />
        <asp:Parameter Name="NCA" Type="String" />
        <asp:Parameter Name="AccessionB" Type="String" />
        <asp:Parameter Name="GIB" Type="String" />
        <asp:Parameter Name="NCB" Type="String" />
        <asp:Parameter Name="Geography" Type="String" />
        <asp:Parameter Name="Year2007A" Type="String" />
        <asp:Parameter Name="Year2007B" Type="String" />
        <asp:Parameter Name="Year2008A" Type="String" />
        <asp:Parameter Name="Year2008B" Type="String" />
        <asp:Parameter Name="Year2009A" Type="String" />
        <asp:Parameter Name="Year2009B" Type="String" />
        <asp:Parameter Name="Year2010A" Type="String" />
        <asp:Parameter Name="Year2010B" Type="String" />
        <asp:Parameter Name="Year2011A" Type="String" />
        <asp:Parameter Name="Year2011B" Type="String" />
        <asp:Parameter Name="original_VID" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDSFamilyDD" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
        SelectCommand="SELECT DISTINCT [Family] FROM [PlantssDNA] ORDER BY [Family]">
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDSGenusDD" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
        SelectCommand="SELECT DISTINCT [Genus] FROM [PlantssDNA] WHERE ([Family] = @Family)">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlFamily" Name="Family" 
                    PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="SqlDSSpeciesDD" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
        SelectCommand="SELECT DISTINCT [Species] FROM [PlantssDNA] WHERE (([Family] = @Family) AND ([Genus] = @Genus)) ORDER BY [Species]">
            <SelectParameters>
                <asp:ControlParameter ControlID="ddlFamily" Name="Family" 
                    PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="ddlGenus" Name="Genus" 
                    PropertyName="SelectedValue" Type="String" />
            </SelectParameters>
    </asp:SqlDataSource>
    
<asp:SqlDataSource ID="SqlDSFamily" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
        DeleteCommand="DELETE FROM [PlantssDNA] WHERE [VID] = @original_VID" 
        InsertCommand="INSERT INTO [PlantssDNA] ([Family], [SubFamily], [Genus], [SubGenus], [Species], [Isolate], [Abbreviation], [AccessionA], [GIA] [NCA], [AccessionB], [GIB], [NCB], [Geography], [Year2007A], [Year2007B], [Year2008A], [Year2008B], [Year2009A], [Year2009B], [Year2010A], [Year2010B], [Year2011A], [Year2011B]) VALUES (@Family, @SubFamily, @Genus, @SubGenus, @Species, @Isolate, @Abbreviation, @AccessionA, @GIA, @NCA, @AccessionB, @GIB, @NCB, @Geography, @Year2007A, @Year2007B, @Year2008A, @Year2008B, @Year2009A, @Year2009B, @Year2010A, @Year2010B, @Year2011A, @Year2011B)" 
        OldValuesParameterFormatString="original_{0}" 
        SelectCommand="SELECT * FROM [PlantssDNA] WHERE ([Family] = @Family) ORDER BY [Family], [Genus], [Species]" 
        UpdateCommand="UPDATE [PlantssDNA] SET [Family] = @Family, [SubFamily] = @SubFamily, [Genus] = @Genus, [SubGenus] = @SubGenus, [Species] = @Species, [Isolate] = @Isolate, [Abbreviation] = @Abbreviation, [AccessionA] = @AccessionA, [GIA] = @GIA, [NCA] = @NCA, [AccessionB] = @AccessionB, [GIB] = @GIB, [NCB] = @NCB, [Geography] = @Geography, [Year2007A] = @Year2007A, [Year2007B] = @Year2007B, [Year2008A] = @Year2008A, [Year2008B] = @Year2008B, [Year2009A] = @Year2009A, [Year2009B] = @Year2009B, [Year2010A] = @Year2010A, [Year2010B] = @Year2010B, [Year2011A] = @Year2011A, [Year2011B] = @Year2011B WHERE [VID] = @original_VID">
        <DeleteParameters>
            <asp:Parameter Name="original_VID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
        <asp:Parameter Name="Family" Type="String" />
        <asp:Parameter Name="SubFamily" Type="String" />
        <asp:Parameter Name="Genus" Type="String" />
        <asp:Parameter Name="SubGenus" Type="String" />
        <asp:Parameter Name="Species" Type="String" />
        <asp:Parameter Name="Isolate" Type="String" />
        <asp:Parameter Name="Abbreviation" Type="String" />
        <asp:Parameter Name="AccessionA" Type="String" />
        <asp:Parameter Name="GIA" Type="String" />
        <asp:Parameter Name="NCA" Type="String" />
        <asp:Parameter Name="AccessionB" Type="String" />
        <asp:Parameter Name="GIB" Type="String" />
        <asp:Parameter Name="NCB" Type="String" />
        <asp:Parameter Name="Geography" Type="String" />
        <asp:Parameter Name="Year2007A" Type="String" />
        <asp:Parameter Name="Year2007B" Type="String" />
        <asp:Parameter Name="Year2008A" Type="String" />
        <asp:Parameter Name="Year2008B" Type="String" />
        <asp:Parameter Name="Year2009A" Type="String" />
        <asp:Parameter Name="Year2009B" Type="String" />
        <asp:Parameter Name="Year2010A" Type="String" />
        <asp:Parameter Name="Year2010B" Type="String" />
        <asp:Parameter Name="Year2011A" Type="String" />
        <asp:Parameter Name="Year2011B" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlFamily" Name="Family" 
                PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
        <UpdateParameters>
        <asp:Parameter Name="Family" Type="String" />
        <asp:Parameter Name="SubFamily" Type="String" />
        <asp:Parameter Name="Genus" Type="String" />
        <asp:Parameter Name="SubGenus" Type="String" />
        <asp:Parameter Name="Species" Type="String" />
        <asp:Parameter Name="Isolate" Type="String" />
        <asp:Parameter Name="Abbreviation" Type="String" />
        <asp:Parameter Name="AccessionA" Type="String" />
        <asp:Parameter Name="GIA" Type="String" />
        <asp:Parameter Name="NCA" Type="String" />
        <asp:Parameter Name="AccessionB" Type="String" />
        <asp:Parameter Name="GIB" Type="String" />
        <asp:Parameter Name="NCB" Type="String" />
        <asp:Parameter Name="Geography" Type="String" />
        <asp:Parameter Name="Year2007A" Type="String" />
        <asp:Parameter Name="Year2007B" Type="String" />
        <asp:Parameter Name="Year2008A" Type="String" />
        <asp:Parameter Name="Year2008B" Type="String" />
        <asp:Parameter Name="Year2009A" Type="String" />
        <asp:Parameter Name="Year2009B" Type="String" />
        <asp:Parameter Name="Year2010A" Type="String" />
        <asp:Parameter Name="Year2010B" Type="String" />
        <asp:Parameter Name="Year2011A" Type="String" />
        <asp:Parameter Name="Year2011B" Type="String" />
            <asp:Parameter Name="original_VID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

<asp:SqlDataSource ID="SqlDSGenus" runat="server" 
    ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
    DeleteCommand="DELETE FROM [PlantssDNA] WHERE [VID] = @original_VID" 
    InsertCommand="INSERT INTO [PlantssDNA] ([Family], [SubFamily], [Genus], [SubGenus], [Species], [Isolate], [Abbreviation], [AccessionA], [GIA], [NCA], [AccessionB], [GIB], [NCB], [Geography], [Year2007A], [Year2007B], [Year2008A], [Year2008B], [Year2009A], [Year2009B], [Year2010A], [Year2010B], [Year2011A], [Year2011B]) VALUES (@Family, @SubFamily, @Genus, @SubGenus, @Species, @Isolate, @Abbreviation, @AccessionA, @GIA, @NCA, @AccessionB, @GIB, @NCB, @Geography, @Year2007A, @Year2007B, @Year2008A, @Year2008B, @Year2009A, @Year2009B, @Year2010A, @Year2010B, @Year2011A, @Year2011B)" 
    OldValuesParameterFormatString="original_{0}" 
    SelectCommand="SELECT * FROM [PlantssDNA] WHERE (([Family] = @Family) AND ([Genus] = @Genus)) ORDER BY [Family], [Genus], [Species]" 
    UpdateCommand="UPDATE [PlantssDNA] SET [Family] = @Family, [SubFamily] = @SubFamily, [Genus] = @Genus, [SubGenus] = @SubGenus, [Species] = @Species, [Isolate] = @Isolate, [Abbreviation] = @Abbreviation, [AccessionA] = @AccessionA, [GIA] = @GIA, [NCA] = @NCA, [AccessionB] = @AccessionB, [GIB] = @GIB, [NCB] = @NCB, [Geography] = @Geography, [Year2007A] = @Year2007A, [Year2007B] = @Year2007B, [Year2008A] = @Year2008A, [Year2008B] = @Year2008B, [Year2009A] = @Year2009A, [Year2009B] = @Year2009B, [Year2010A] = @Year2010A, [Year2010B] = @Year2010B, [Year2011A] = @Year2011A, [Year2011B] = @Year2011B WHERE [VID] = @original_VID">
    <DeleteParameters>
        <asp:Parameter Name="original_VID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="Family" Type="String" />
        <asp:Parameter Name="SubFamily" Type="String" />
        <asp:Parameter Name="Genus" Type="String" />
        <asp:Parameter Name="SubGenus" Type="String" />
        <asp:Parameter Name="Species" Type="String" />
        <asp:Parameter Name="Isolate" Type="String" />
        <asp:Parameter Name="Abbreviation" Type="String" />
        <asp:Parameter Name="AccessionA" Type="String" />
        <asp:Parameter Name="GIA" Type="String" />
        <asp:Parameter Name="NCA" Type="String" />
        <asp:Parameter Name="AccessionB" Type="String" />
        <asp:Parameter Name="GIB" Type="String" />
        <asp:Parameter Name="NCB" Type="String" />
        <asp:Parameter Name="Geography" Type="String" />
        <asp:Parameter Name="Year2007A" Type="String" />
        <asp:Parameter Name="Year2007B" Type="String" />
        <asp:Parameter Name="Year2008A" Type="String" />
        <asp:Parameter Name="Year2008B" Type="String" />
        <asp:Parameter Name="Year2009A" Type="String" />
        <asp:Parameter Name="Year2009B" Type="String" />
        <asp:Parameter Name="Year2010A" Type="String" />
        <asp:Parameter Name="Year2010B" Type="String" />
        <asp:Parameter Name="Year2011A" Type="String" />
        <asp:Parameter Name="Year2011B" Type="String" />
    </InsertParameters>
    <SelectParameters>
        <asp:ControlParameter ControlID="ddlFamily" Name="Family" 
            PropertyName="SelectedValue" Type="String" />
        <asp:ControlParameter ControlID="ddlGenus" Name="Genus" 
            PropertyName="SelectedValue" Type="String" />
    </SelectParameters>
    <UpdateParameters>
        <asp:Parameter Name="Family" Type="String" />
        <asp:Parameter Name="SubFamily" Type="String" />
        <asp:Parameter Name="Genus" Type="String" />
        <asp:Parameter Name="SubGenus" Type="String" />
        <asp:Parameter Name="Species" Type="String" />
        <asp:Parameter Name="Isolate" Type="String" />
        <asp:Parameter Name="Abbreviation" Type="String" />
        <asp:Parameter Name="AccessionA" Type="String" />
        <asp:Parameter Name="GIA" Type="String" />
        <asp:Parameter Name="NCA" Type="String" />
        <asp:Parameter Name="AccessionB" Type="String" />
        <asp:Parameter Name="GIB" Type="String" />
        <asp:Parameter Name="NCB" Type="String" />
        <asp:Parameter Name="Geography" Type="String" />
        <asp:Parameter Name="Year2007A" Type="String" />
        <asp:Parameter Name="Year2007B" Type="String" />
        <asp:Parameter Name="Year2008A" Type="String" />
        <asp:Parameter Name="Year2008B" Type="String" />
        <asp:Parameter Name="Year2009A" Type="String" />
        <asp:Parameter Name="Year2009B" Type="String" />
        <asp:Parameter Name="Year2010A" Type="String" />
        <asp:Parameter Name="Year2010B" Type="String" />
        <asp:Parameter Name="Year2011A" Type="String" />
        <asp:Parameter Name="Year2011B" Type="String" />
        <asp:Parameter Name="original_VID" Type="Int32" />
    </UpdateParameters>

</asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDSSpecies" runat="server" 
    ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
    DeleteCommand="DELETE FROM [PlantssDNA] WHERE [VID] = @original_VID" 
    InsertCommand="INSERT INTO [PlantssDNA] ([Family], [SubFamily], [Genus], [SubGenus], [Species], [Isolate], [Abbreviation], [AccessionA], [GIA] [NCA], [AccessionB], [GIB], [NCB], [Geography], [Year2007A], [Year2007B], [Year2008A], [Year2008B], [Year2009A], [Year2009B], [Year2010A], [Year2010B], [Year2011A], [Year2011B]) VALUES (@Family, @SubFamily, @Genus, @SubGenus, @Species, @Isolate, @Abbreviation, @AccessionA, @GIA, @NCA, @AccessionB, @GIB, @NCB, @Geography, @Year2007A, @Year2007B, @Year2008A, @Year2008B, @Year2009A, @Year2009B, @Year2010A, @Year2010B, @Year2011A, @Year2011B)" 
    OldValuesParameterFormatString="original_{0}" 
    SelectCommand="SELECT * FROM [PlantssDNA] WHERE (([Family] = @Family) AND ([Genus] = @Genus) AND ([Species] = @Species)) ORDER BY [Family], [Genus], [Species]" 
    UpdateCommand="UPDATE [PlantssDNA] SET [Family] = @Family, [SubFamily] = @SubFamily, [Genus] = @Genus, [SubGenus] = @SubGenus, [Species] = @Species, [Isolate] = @Isolate, [Abbreviation] = @Abbreviation, [AccessionA] = @AccessionA, [GIA] = @GIA, [NCA] = @NCA, [AccessionB] = @AccessionB, [GIB] = @GIB, [NCB] = @NCB, [Geography] = @Geography, [Year2007A] = @Year2007A, [Year2007B] = @Year2007B, [Year2008A] = @Year2008A, [Year2008B] = @Year2008B, [Year2009A] = @Year2009A, [Year2009B] = @Year2009B, [Year2010A] = @Year2010A, [Year2010B] = @Year2010B, [Year2011A] = @Year2011A, [Year2011B] = @Year2011B WHERE [VID] = @original_VID">
        <DeleteParameters>
            <asp:Parameter Name="original_VID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
        <asp:Parameter Name="Family" Type="String" />
        <asp:Parameter Name="SubFamily" Type="String" />
        <asp:Parameter Name="Genus" Type="String" />
        <asp:Parameter Name="SubGenus" Type="String" />
        <asp:Parameter Name="Species" Type="String" />
        <asp:Parameter Name="Isolate" Type="String" />
        <asp:Parameter Name="Abbreviation" Type="String" />
        <asp:Parameter Name="AccessionA" Type="String" />
        <asp:Parameter Name="GIA" Type="String" />
        <asp:Parameter Name="NCA" Type="String" />
        <asp:Parameter Name="AccessionB" Type="String" />
        <asp:Parameter Name="GIB" Type="String" />
        <asp:Parameter Name="NCB" Type="String" />
        <asp:Parameter Name="Geography" Type="String" />
        <asp:Parameter Name="Year2007A" Type="String" />
        <asp:Parameter Name="Year2007B" Type="String" />
        <asp:Parameter Name="Year2008A" Type="String" />
        <asp:Parameter Name="Year2008B" Type="String" />
        <asp:Parameter Name="Year2009A" Type="String" />
        <asp:Parameter Name="Year2009B" Type="String" />
        <asp:Parameter Name="Year2010A" Type="String" />
        <asp:Parameter Name="Year2010B" Type="String" />
        <asp:Parameter Name="Year2011A" Type="String" />
        <asp:Parameter Name="Year2011B" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="ddlFamily" Name="Family" 
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="ddlGenus" Name="Genus" 
                PropertyName="SelectedValue" Type="String" />
            <asp:ControlParameter ControlID="ddlSpecies" Name="Species" 
                PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
        <UpdateParameters>
        <asp:Parameter Name="Family" Type="String" />
        <asp:Parameter Name="SubFamily" Type="String" />
        <asp:Parameter Name="Genus" Type="String" />
        <asp:Parameter Name="SubGenus" Type="String" />
        <asp:Parameter Name="Species" Type="String" />
        <asp:Parameter Name="Isolate" Type="String" />
        <asp:Parameter Name="Abbreviation" Type="String" />
        <asp:Parameter Name="AccessionA" Type="String" />
        <asp:Parameter Name="GIA" Type="String" />
        <asp:Parameter Name="NCA" Type="String" />
        <asp:Parameter Name="AccessionB" Type="String" />
        <asp:Parameter Name="GIB" Type="String" />
        <asp:Parameter Name="NCB" Type="String" />
        <asp:Parameter Name="Geography" Type="String" />
        <asp:Parameter Name="Year2007A" Type="String" />
        <asp:Parameter Name="Year2007B" Type="String" />
        <asp:Parameter Name="Year2008A" Type="String" />
        <asp:Parameter Name="Year2008B" Type="String" />
        <asp:Parameter Name="Year2009A" Type="String" />
        <asp:Parameter Name="Year2009B" Type="String" />
        <asp:Parameter Name="Year2010A" Type="String" />
        <asp:Parameter Name="Year2010B" Type="String" />
        <asp:Parameter Name="Year2011A" Type="String" />
        <asp:Parameter Name="Year2011B" Type="String" />
            <asp:Parameter Name="original_VID" Type="Int32" />
        </UpdateParameters>
</asp:SqlDataSource>

    <asp:SqlDataSource ID="SqlDSSearchVName" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
        DeleteCommand="DELETE FROM [PlantssDNA] WHERE [VID] = @VID" 
        InsertCommand="INSERT INTO [PlantssDNA] ([Family], [SubFamily], [Genus], [SubGenus], [Species], [Isolate], [Abbreviation], [AccessionA], [GIA], [NCA], [AccessionB], [GIB], [NCB], [Geography], [Year2007A], [Year2007B], [Year2008A], [Year2008B], [Year2009A], [Year2009B], [Year2010A], [Year2010B], [Year2011A], [Year2011B]) VALUES (@Family, @SubFamily, @Genus, @SubGenus, @Species, @Isolate, @Abbreviation, @AccessionA, @GIA, @NCA, @AccessionB, @GIB, @NCB, @Geography, @Year2007A, @Year2007B, @Year2008A, @Year2008B, @Year2009A, @Year2009B, @Year2010A, @Year2010B, @Year2011A, @Year2011B)" 
        SelectCommand="SELECT * FROM [PlantssDNA] WHERE (([Isolate] LIKE '%' + @Isolate + '%') OR ([Species] LIKE '%' + @Species + '%')) ORDER BY [Family], [Genus], [Species]" 
        UpdateCommand="UPDATE [PlantssDNA] SET [Family] = @Family, [SubFamily] = @SubFamily, [Genus] = @Genus, [SubGenus] = @SubGenus, [Species] = @Species, [Isolate] = @Isolate, [Abbreviation] = @Abbreviation, [AccessionA] = @AccessionA, [GIA] = @GIA, [NCA] = @NCA, [AccessionB] = @AccessionB, [GIB] = @GIB, [NCB] = @NCB, [Geography] = @Geography, [Year2007A] = @Year2007A, [Year2007B] = @Year2007B, [Year2008A] = @Year2008A, [Year2008B] = @Year2008B, [Year2009A] = @Year2009A, [Year2009B] = @Year2009B, [Year2010A] = @Year2010A, [Year2010B] = @Year2010B, [Year2011A] = @Year2011A, [Year2011B] = @Year2011B WHERE [VID] = @VID">
        <DeleteParameters>
            <asp:Parameter Name="VID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Family" Type="String" />
            <asp:Parameter Name="SubFamily" Type="String" />
            <asp:Parameter Name="Genus" Type="String" />
            <asp:Parameter Name="SubGenus" Type="String" />
            <asp:Parameter Name="Species" Type="String" />
            <asp:Parameter Name="Isolate" Type="String" />
            <asp:Parameter Name="Abbreviation" Type="String" />
            <asp:Parameter Name="AccessionA" Type="String" />
            <asp:Parameter Name="GIA" Type="String" />
            <asp:Parameter Name="NCA" Type="String" />
            <asp:Parameter Name="AccessionB" Type="String" />
            <asp:Parameter Name="GIB" Type="String" />
            <asp:Parameter Name="NCB" Type="String" />
            <asp:Parameter Name="Geography" Type="String" />
            <asp:Parameter Name="Year2007A" Type="String" />
            <asp:Parameter Name="Year2007B" Type="String" />
            <asp:Parameter Name="Year2008A" Type="String" />
            <asp:Parameter Name="Year2008B" Type="String" />
            <asp:Parameter Name="Year2009A" Type="String" />
            <asp:Parameter Name="Year2009B" Type="String" />
            <asp:Parameter Name="Year2010A" Type="String" />
            <asp:Parameter Name="Year2010B" Type="String" />
            <asp:Parameter Name="Year2011A" Type="String" />
            <asp:Parameter Name="Year2011B" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="txtSearchVName" Name="Isolate" PropertyName="Text" 
                Type="String" />
            <asp:ControlParameter ControlID="txtSearchVName" Name="Species" PropertyName="Text" 
                Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Family" Type="String" />
            <asp:Parameter Name="SubFamily" Type="String" />
            <asp:Parameter Name="Genus" Type="String" />
            <asp:Parameter Name="SubGenus" Type="String" />
            <asp:Parameter Name="Species" Type="String" />
            <asp:Parameter Name="Isolate" Type="String" />
            <asp:Parameter Name="Abbreviation" Type="String" />
            <asp:Parameter Name="AccessionA" Type="String" />
            <asp:Parameter Name="GIA" Type="String" />
            <asp:Parameter Name="NCA" Type="String" />
            <asp:Parameter Name="AccessionB" Type="String" />
            <asp:Parameter Name="GIB" Type="String" />
            <asp:Parameter Name="NCB" Type="String" />
            <asp:Parameter Name="Geography" Type="String" />
            <asp:Parameter Name="Year2007A" Type="String" />
            <asp:Parameter Name="Year2007B" Type="String" />
            <asp:Parameter Name="Year2008A" Type="String" />
            <asp:Parameter Name="Year2008B" Type="String" />
            <asp:Parameter Name="Year2009A" Type="String" />
            <asp:Parameter Name="Year2009B" Type="String" />
            <asp:Parameter Name="Year2010A" Type="String" />
            <asp:Parameter Name="Year2010B" Type="String" />
            <asp:Parameter Name="Year2011A" Type="String" />
            <asp:Parameter Name="Year2011B" Type="String" />
            <asp:Parameter Name="VID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDSSearchAccession" runat="server" 
        ConnectionString="<%$ ConnectionStrings:PlantssDNAVirusesConnectionString %>" 
        DeleteCommand="DELETE FROM [PlantssDNA] WHERE [VID] = @VID" 
        InsertCommand="INSERT INTO [PlantssDNA] ([Family], [SubFamily], [Genus], [SubGenus], [Species], [Isolate], [Abbreviation], [AccessionA], [GIA], [NCA], [AccessionB], [GIB], [NCB], [Geography], [Year2007A], [Year2007B], [Year2008A], [Year2008B], [Year2009A], [Year2009B], [Year2010A], [Year2010B], [Year2011A], [Year2011B]) VALUES (@Family, @SubFamily, @Genus, @SubGenus, @Species, @Isolate, @Abbreviation, @AccessionA, @GIA, @NCA, @AccessionB, @GIB, @NCB, @Geography, @Year2007A, @Year2007B, @Year2008A, @Year2008B, @Year2009A, @Year2009B, @Year2010A, @Year2010B, @Year2011A, @Year2011B)" 
        SelectCommand="SELECT * FROM [PlantssDNA] WHERE (([AccessionA] LIKE '%' + @AccessionA + '%') OR ([AccessionB] LIKE '%' + @AccessionB + '%')) ORDER BY [Family], [Genus], [Species]" 
        UpdateCommand="UPDATE [PlantssDNA] SET [Family] = @Family, [SubFamily] = @SubFamily, [Genus] = @Genus, [SubGenus] = @SubGenus, [Species] = @Species, [Isolate] = @Isolate, [Abbreviation] = @Abbreviation, [AccessionA] = @AccessionA, [GIA] = @GIA, [NCA] = @NCA, [AccessionB] = @AccessionB, [GIB] = @GIB, [NCB] = @NCB, [Geography] = @Geography, [Year2007A] = @Year2007A, [Year2007B] = @Year2007B, [Year2008A] = @Year2008A, [Year2008B] = @Year2008B, [Year2009A] = @Year2009A, [Year2009B] = @Year2009B, [Year2010A] = @Year2010A, [Year2010B] = @Year2010B, [Year2011A] = @Year2011A, [Year2011B] = @Year2011B WHERE [VID] = @VID">
        <DeleteParameters>
            <asp:Parameter Name="VID" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="Family" Type="String" />
            <asp:Parameter Name="SubFamily" Type="String" />
            <asp:Parameter Name="Genus" Type="String" />
            <asp:Parameter Name="SubGenus" Type="String" />
            <asp:Parameter Name="Species" Type="String" />
            <asp:Parameter Name="Isolate" Type="String" />
            <asp:Parameter Name="Abbreviation" Type="String" />
            <asp:Parameter Name="AccessionA" Type="String" />
            <asp:Parameter Name="GIA" Type="String" />
            <asp:Parameter Name="NCA" Type="String" />
            <asp:Parameter Name="AccessionB" Type="String" />
            <asp:Parameter Name="GIB" Type="String" />
            <asp:Parameter Name="NCB" Type="String" />
            <asp:Parameter Name="Geography" Type="String" />
            <asp:Parameter Name="Year2007A" Type="String" />
            <asp:Parameter Name="Year2007B" Type="String" />
            <asp:Parameter Name="Year2008A" Type="String" />
            <asp:Parameter Name="Year2008B" Type="String" />
            <asp:Parameter Name="Year2009A" Type="String" />
            <asp:Parameter Name="Year2009B" Type="String" />
            <asp:Parameter Name="Year2010A" Type="String" />
            <asp:Parameter Name="Year2010B" Type="String" />
            <asp:Parameter Name="Year2011A" Type="String" />
            <asp:Parameter Name="Year2011B" Type="String" />
        </InsertParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="txtSearchAccession" Name="AccessionA" 
                PropertyName="Text" Type="String" />
            <asp:ControlParameter ControlID="txtSearchAccession" Name="AccessionB" 
                PropertyName="Text" Type="String" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="Family" Type="String" />
            <asp:Parameter Name="SubFamily" Type="String" />
            <asp:Parameter Name="Genus" Type="String" />
            <asp:Parameter Name="SubGenus" Type="String" />
            <asp:Parameter Name="Species" Type="String" />
            <asp:Parameter Name="Isolate" Type="String" />
            <asp:Parameter Name="Abbreviation" Type="String" />
            <asp:Parameter Name="AccessionA" Type="String" />
            <asp:Parameter Name="GIA" Type="String" />
            <asp:Parameter Name="NCA" Type="String" />
            <asp:Parameter Name="AccessionB" Type="String" />
            <asp:Parameter Name="GIB" Type="String" />
            <asp:Parameter Name="NCB" Type="String" />
            <asp:Parameter Name="Geography" Type="String" />
            <asp:Parameter Name="Year2007A" Type="String" />
            <asp:Parameter Name="Year2007B" Type="String" />
            <asp:Parameter Name="Year2008A" Type="String" />
            <asp:Parameter Name="Year2008B" Type="String" />
            <asp:Parameter Name="Year2009A" Type="String" />
            <asp:Parameter Name="Year2009B" Type="String" />
            <asp:Parameter Name="Year2010A" Type="String" />
            <asp:Parameter Name="Year2010B" Type="String" />
            <asp:Parameter Name="Year2011A" Type="String" />
            <asp:Parameter Name="Year2011B" Type="String" />
            <asp:Parameter Name="VID" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <strong>Search by</strong><span class="style1">&nbsp;&nbsp; Virus Name:</span>
    <asp:TextBox ID="txtSearchVName" runat="server" Width="250px"></asp:TextBox>
    <asp:Button ID="btnSearchVName" runat="server" Text="Search" />
&nbsp; <strong>OR</strong> &nbsp;<span class="style1">Accession#:</span> 
    <asp:TextBox ID="txtSearchAccession" runat="server" Width="100px"></asp:TextBox>
    <asp:Button ID="btnSearchAccession" runat="server" Text="Search" />
&nbsp; <strong>OR</strong>&nbsp;&nbsp; <asp:Button ID="btnShowAllRec" runat="server" Text="Show All Records" />
    <br />
    <br />
    <strong>Search by&nbsp;&nbsp; </strong> </strong><span class="style1">Family</span>:
    <asp:DropDownList ID="ddlFamily" runat="server" AutoPostBack="True" 
        DataSourceID="SqlDSFamilyDD" DataTextField="Family" 
        DataValueField="Family">
    </asp:DropDownList>
    &nbsp;&nbsp;<span class="style1">Genus:</span> 
    <asp:DropDownList ID="ddlGenus" runat="server" AutoPostBack="True"
        DataSourceID="SqlDSGenusDD" 
        DataTextField="Genus" DataValueField="Genus">
    </asp:DropDownList>
    &nbsp;&nbsp;<span class="style1">Species:</span>
    <asp:DropDownList ID="ddlSpecies" runat="server" AutoPostBack="True"
        DataSourceID="SqlDSSpeciesDD" 
        DataTextField="Species" DataValueField="Species">
    </asp:DropDownList>
    &nbsp;
    <br />
    <br />
    <strong>Records to display per page:&nbsp;
    <asp:DropDownList ID="ddlRowsPerPage" runat="server" AutoPostBack="True">
        <asp:ListItem Value="20"></asp:ListItem>
        <asp:ListItem Value="50"></asp:ListItem>
        <asp:ListItem Value="100"></asp:ListItem>
        <asp:ListItem Value="5000">ALL</asp:ListItem>
    </asp:DropDownList>
    &nbsp;&nbsp; Record Count:</strong>
    <asp:Label ID="lblRecordCount" runat="server" Text="0" ForeColor="#009900" 
        Font-Size="Medium" Font-Bold="True"></asp:Label>
    &nbsp;&nbsp;
    <asp:Button ID="btnExportCSV" runat="server" Text="Export Results" 
        OnClick="btnExportCSV_Click" />
    &nbsp; <strong>OR</strong>&nbsp;&nbsp;
    <input id="btnInsertRec" type="button" value="Insert Record" onclick="location.href='InsertRecord.aspx';" /><br />
    <br />

     
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
    AllowSorting="True" CellPadding="4" DataSourceID="SqlDSALL" 
    ForeColor="#333333" GridLines="None" HorizontalAlign="Left" PageSize="20" 
    AutoGenerateColumns="False" CellSpacing="1" DataKeyNames="VID" 
    EnablePersistedSelection="True">
    <AlternatingRowStyle BackColor="White" BorderStyle="Solid" />
    <Columns>
        <asp:CommandField ShowEditButton="True" />
        <asp:TemplateField ShowHeader="false">
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Delete"
                     OnClientClick='return confirm("Are you sure you want to delete this entry?");'
                     Text="Delete" ForeColor="#CC0000" />
            </ItemTemplate>
        </asp:TemplateField>
        <asp:BoundField DataField="VID" HeaderText="VID" InsertVisible="False" 
            ReadOnly="True" SortExpression="VID" Visible="False" />
        <asp:BoundField DataField="Family" HeaderText="Family" 
            SortExpression="Family" >
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="SubFamily" HeaderText="SubFamily" 
            SortExpression="SubFamily" >
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="Genus" HeaderText="Genus" SortExpression="Genus" >
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="SubGenus" HeaderText="SubGenus" 
            SortExpression="SubGenus" >
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="Species" HeaderText="Species" 
            SortExpression="Species" >
        <ControlStyle Width="500px" />
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="Isolate" HeaderText="Isolate" 
            SortExpression="Isolate" >
        <ControlStyle Width="500px" />
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="Abbreviation" HeaderText="Abbreviation" 
            SortExpression="Abbreviation" >
        <ControlStyle Width="500px" />
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        
        <asp:TemplateField HeaderText="AccessionA" SortExpression="AccessionA" >
            <ItemTemplate>
                <a href='<%# "http://www.ncbi.nlm.nih.gov/nuccore/" & Eval("AccessionA") %>'target="_blank"><%#Eval("AccessionA")%></a>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
        </asp:TemplateField>
                <asp:BoundField DataField="GIA" HeaderText="GIA" SortExpression="GIA" >
        <ItemStyle HorizontalAlign="Right" />
        </asp:BoundField>

         <asp:BoundField DataField="NCA" HeaderText="NCA" SortExpression="NCA" >
        <ItemStyle HorizontalAlign="Right" />
        </asp:BoundField>

        <asp:TemplateField HeaderText="AccessionB" SortExpression="AccessionB" >
            <ItemTemplate>
                <a href='<%# "http://www.ncbi.nlm.nih.gov/nuccore/" & Eval("AccessionB") %>'target="_blank"><%#Eval("AccessionB")%></a>
            </ItemTemplate>
            <ItemStyle HorizontalAlign="Right" />
        </asp:TemplateField>

        <asp:BoundField DataField="GIB" HeaderText="GIB" SortExpression="GIB" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="NCB" HeaderText="NCB" SortExpression="NCB" >
        <ItemStyle HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Geography" HeaderText="Geography" 
            SortExpression="Geography" >
        <ItemStyle Wrap="False" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2007A" HeaderText="2007A" 
            SortExpression="Year2007A" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2007B" HeaderText="2007B" 
            SortExpression="Year2007B" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2008A" HeaderText="2008A" 
            SortExpression="Year2008A" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2008B" HeaderText="2008B" 
            SortExpression="Year2008B" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2009A" HeaderText="2009A" 
            SortExpression="Year2009A" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2009B" HeaderText="2009B" 
            SortExpression="Year2009B" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2010A" HeaderText="2010A" 
            SortExpression="Year2010A" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2010B" HeaderText="2010B" 
            SortExpression="Year2010B" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2011A" HeaderText="2011A" 
            SortExpression="Year2011A" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
        <asp:BoundField DataField="Year2011B" HeaderText="2011B" 
            SortExpression="Year2011B" >
        <ItemStyle Wrap="False" HorizontalAlign="Right" />
        </asp:BoundField>
    </Columns>
    <EditRowStyle BackColor="#FFFF66" />
    <EmptyDataTemplate>
        <br />
        No records found matching criteria.
        <br />
    </EmptyDataTemplate>
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" />
    <PagerStyle BackColor="#507CD1" ForeColor="White" HorizontalAlign="Left" 
        VerticalAlign="Middle" Font-Bold="True" Font-Size="Medium" />
    <RowStyle BackColor="#EFF3FB" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="False" ForeColor="#333333" />
    <SortedAscendingCellStyle BackColor="#F5F7FB" />
    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
    <SortedDescendingCellStyle BackColor="#E9EBEF" />
    <SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>
    <br />

</asp:Content>

Open in new window

Family,SubFamily,Genus,SubGenus,Species,Isolate,Abbreviation,AccessionA,GIA,NCA,AccessionB,GIB,NCB,Geography,2007A,2007B,2008A,2008B,2009A,2009B,2010A,2010B,2011A,2011B,
Alphasatellitidae,Ayelalphasatellitinae,Ayelalphasatellitus,,Ageratum yellow vein Singapore alphasatellite,Ageratum yellow vein Singapore alphasatellite-[Oman:Batina:2005],AYVSGA-[OM:Bat:05],,,,,,,,,,,,,,1,,,,
Alphasatellitidae,Ayelalphasatellitinae,Ayelalphasatellitus,,Ageratum yellow vein Singapore alphasatellite,Ageratum yellow vein Singapore alphasatellite-[Oman:Oman:Tomato:2005],AYVSGA-[OM:Oma:To:05],,,,,,,,,,,,,,1,,,,
Alphasatellitidae,Ayelalphasatellitinae,Ayelalphasatellitus,,Ageratum yellow vein Singapore alphasatellite,Ageratum yellow vein Singapore alphasatellite-[Singapore;1998],AYVSGA-[SG;98],,,,,,,,,,,,,,,,,,

Open in new window

AhelblingAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kamal KhaleefaInformation Security SpecialistCommented:
maybe because of this
 For k As Integer = 3 To GridView1.Columns.Count - 1
try to do it like this
 For k As Integer = 0 To GridView1.Columns.Count - 1
0
Robberbaron (robr)Commented:
the difference is that the accession fields are template items, returning a href , where the other fields are text.
   
If String.IsNullOrWhiteSpace(strVal) Or String.Equals(strVal, "&nbsp;") Then

Open in new window

must be evaluating as null or empty


ie the text property of the cell is empty, despite showing on screen.  from MSDN,  http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.tablecell.aspx      Text   =     Gets or sets the text contents of the cell.

can you test exactly what is in the cell ?  split out the tests for Null, Empty & nbsp.

Did you mean to overwrite cell values when doing the export rathe rthan exporting the text property ?





For i As Integer = 0 To GridView1.Rows.Count - 1
            gridrow = Gridview1.Rows(i)  'return entire row
            For k As Integer = 3 To GridView1.Columns.Count - 1

                Dim strVal = gridrow.Cells(k).Text
                If String.IsNullOrWhiteSpace(strVal) then
                    strVal = "zz0"  'testing
                Elseif String.Equals(strVal, "&nbsp;") Then
                    strVal = "zz1"  'testing
                Else
                End If

                'add separator
                sb.Append(strVal + ","c)
            Next

Open in new window

0
AhelblingAuthor Commented:
I will give both of those suggestions a shot and let you know as soon as I get to the office in an hour or so.  Thanks for your help thus far.
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

AhelblingAuthor Commented:
I stripped out the checks for null etc and this is what I come up with now:
It still skips over the Accession template  fields?

 
Family,SubFamily,Genus,SubGenus,Species,Isolate,Abbreviation,AccessionA,GIA,NCA,AccessionB,GIB,NCB,Geography,2007A,2007B,2008A,2008B,2009A,2009B,2010A,2010B,2011A,2011B,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 1,&nbsp;,Faba bean necrotic yellow C1 alphasatellite,Faba bean necrotic yellow C11 alphasatellite-[Egypt:C1;1993],FBNYC1A-[EG:C11;93],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 1,&nbsp;,Faba bean necrotic yellow C1b alphasatellite,Faba bean necrotic yellow C1 alphasatellite-[Syria:C1;1988],FBNYC1A-[SY:C1;88],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 1,&nbsp;,Milk vetch dwarf C2 alphasatellite,Milk vetch dwarf C2 alphasatellite-[Japan:C2],MVDC2A-[JR:C2],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 1,&nbsp;,Subterranean clover stunt C2 alphasatellite,Subterranean clover stunt C2 alphasatellite-[Australia:C2],SCSC2A-[AU:C2],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top H4 alphasatellite,Banana bunchy top H4 alphasatellite-[Taiwan:H4],BBTH4A-[TW:H4],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top S1 alphasatellite,Banana bunchy top S1 alphasatellite-[Taiwan:S1],BBTS1A-[TW:S1],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top S1 alphasatellite,Banana bunchy top S1 alphasatellite-[Taiwan:S15],BBTS1A-[TW:S15],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top S3 alphasatellite,Banana bunchy top S3 alphasatellite-[Vietnam:VB:sat3],BBTS3A-[VN:VB:sat3],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top S3 alphasatellite,Banana bunchy top S3 alphasatellite-[Vietnam],BBTS3A-[VN],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top W1 alphasatellite,Banana bunchy top W1 alphasatellite-[Taiwan],BBTW1A-[TW],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top W1 alphasatellite,Banana bunchy top W1 alphasatellite-[Taiwan:W1],BBTW1A-[TW],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top Y alphasatellite,Banana bunchy top Y alphasatellite-[Taiwan:Y],BBTYA-[TW:Y],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 2,&nbsp;,Banana bunchy top Y alphasatellite,Banana bunchy top Y alphasatellite-[Taiwan:Y02],BBTYA-[TW:Y02],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 3,&nbsp;,Banana bunchy top S2 alphasatellite,Banana bunchy top S2 alphasatellite-[Taiwan],BBTS2A-[TW],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 3,&nbsp;,Banana bunchy top S2 alphasatellite,Banana bunchy top S2 alphasatellite-[Taiwan:S2],BBTS2A-[TW:S2],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 3,&nbsp;,Banana bunchy top S2 alphasatellite,Banana bunchy top S2 alphasatellite-[Taiwan:S2],BBTS2A-[TW:S2],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Babalphasatellitinae,Babalphasatellitus 3,&nbsp;,Banana bunchy top S2 alphasatellite,Banana bunchy top S2 alphasatellite-[TW:S2],BBTS2A-[TW:S2],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Nanalphasatellitinae,Nanalphasatellitus 1,&nbsp;,Faba bean necrotic yellow C7 alphasatellite,Faba bean necrotic yellow C7 alphasatellite-[Syria:C7;1988],FBNYC7A-[SY:C7;88],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Nanalphasatellitinae,Nanalphasatellitus 1,&nbsp;,Faba bean necrotic yellow C7 alphasatellite,Faba bean necrotic yellow C7 alphasatellite-[Egypt:C7:1993],FBNYC7A-[EG:C7;93],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Nanalphasatellitinae,Nanalphasatellitus 1,&nbsp;,Milk vetch dwarf C10 alphasatellite,Milk vetch dwarf C10 alphasatellite-[Japan:C10],MVDC10A-[JR:C10],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Nanalphasatellitinae,Nanalphasatellitus 2,&nbsp;,Milk vetch dwarf C3 alphasatellite,Milk vetch dwarf C3 alphasatellite-[Japan:C3],MVDC3A-[JR:C3;96],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Nanalphasatellitinae,Nanalphasatellitus 2,&nbsp;,Subterranean clover stunt C6 alphasatellite,Subterranean clover stunt C6 alphasatellite-[Australia:C6],SCSC6A-[AU:C6],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Nanalphasatellitinae,Nanalphasatellitus 3,&nbsp;,Milk vetch dwarf C1 alphasatellite,Milk vetch dwarf C1 alphasatellite-[Japan:C1],MVDC1A-[JR:C1],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Nanalphasatellitinae,Nanalphasatellitus 4,&nbsp;,Faba bean necrotic yellow C9 alphasatellite,Faba bean necrotic yellow C9 alphasatellite-[Syria:C9;1988],FBNYC9A-[SY:C9;88],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,
Nanosatellitidae,Nanalphasatellitinae,Nanalphasatellitus 4,&nbsp;,Faba bean necrotic yellow C9 alphasatellite,Faba bean necrotic yellow C9 alphasatellite-[Egypt:C9;1993],FBNYC9A-[EG:C9;93],,&nbsp;,&nbsp;,,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,&nbsp;,

Open in new window

0
AhelblingAuthor Commented:
updated code:
Protected Sub btnExportCSV_Click(ByVal sender As Object, ByVal e As EventArgs)
        Response.Clear()
        Response.Buffer = True
        Response.AddHeader("content-disposition", "attachment;filename=PlantssDNAExport.csv")
        Response.Charset = ""
        Response.ContentType = "application/text"

        GridView1.AllowPaging = False
        GridView1.DataBind()

        Dim sb As New StringBuilder()
        For k As Integer = 3 To GridView1.Columns.Count - 1
            'add separator
            sb.Append(GridView1.Columns(k).HeaderText + ","c)
        Next
        'append new line
        sb.Append(vbCr & vbLf)
        For i As Integer = 0 To GridView1.Rows.Count - 1
            For k As Integer = 3 To GridView1.Columns.Count - 1

                'Dim strVal = GridView1.Rows(i).Cells(k).Text
                'If String.IsNullOrWhiteSpace(strVal) Or String.Equals(strVal, "&nbsp;") Then
                'GridView1.Rows(i).Cells(k).Text = ""
                'Else
                'End If

                'add separator
                sb.Append(GridView1.Rows(i).Cells(k).Text + ","c)
            Next
            'append new line
            sb.Append(vbCr & vbLf)
        Next
        Response.Output.Write(sb.ToString())
        Response.Flush()
        Response.End()
    End Sub

Open in new window

0
AhelblingAuthor Commented:
Any other suggestions?

Thanks,
Andrew
0
Robberbaron (robr)Commented:
the text property must be showing as empty, rather than displaying the A HREF code.

1/ what shows when you do a view source of the form before doing the extract > is it all text within <td> markers ?

2/ the cells in concern may have controls within.  this is where I dont have enough experience to get the data out.... http://www.codeproject.com/KB/webforms/EditGridviewCells.aspx
gridView.Rows[_rowIndex].Cells[_columnIndex].Controls[1];  perhaps you can get the HREF out of the control ?

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AhelblingAuthor Commented:
It appears to indeed be a control.  Here is what I came up with, and it seems to be working for now.  Does this offer any new info that may lead to other suggestions now?

Thanks,
Andrew
Protected Sub btnExportCSV_Click(ByVal sender As Object, ByVal e As EventArgs)
        Response.Clear()
        Response.Buffer = True
        Response.AddHeader("content-disposition", "attachment;filename=PlantssDNAExport.csv")
        Response.Charset = ""
        Response.ContentType = "application/text"

        GridView1.AllowPaging = False
        GridView1.DataBind()

        Dim sb As New StringBuilder()
        'build header
        For j As Integer = 3 To GridView1.Columns.Count - 1
            'add separator
            sb.Append(GridView1.Columns(j).HeaderText + ","c)
        Next

        'append new line
        sb.Append(vbCr & vbLf)
        For i As Integer = 0 To GridView1.Rows.Count - 1
            For j As Integer = 3 To GridView1.Columns.Count - 1

                If GridView1.Rows(i).Cells(j).Text = String.Empty Then
                    Dim ctl As DataBoundLiteralControl = _
                        TryCast(GridView1.Rows(i).Cells(j).Controls(0), DataBoundLiteralControl)

                    If ctl IsNot Nothing Then
                        Dim test As String = ctl.Text
                        test = test.Trim
                        test = test.Remove(0, test.LastIndexOfAny("nucore") + 4)
                        test = test.Replace("</a>", "")
                        test = test.Replace("/a>", "")
                        sb.Append(Chr(34) & test & Chr(34) & ",")
                    Else
                    End If

                Else
                    Dim strVal = GridView1.Rows(i).Cells(j).Text
                    If String.IsNullOrWhiteSpace(strVal) Or String.Equals(strVal, "&nbsp;") Then
                        GridView1.Rows(i).Cells(j).Text = ""
                    Else
                    End If

                    sb.Append(GridView1.Rows(i).Cells(j).Text + ","c)
                End If

            Next
            'append new line
            sb.Append(vbCr & vbLf)
        Next
        Response.Output.Write(sb.ToString())
        Response.Flush()
        Response.End()
    End Sub

Open in new window

0
AhelblingAuthor Commented:
View source =  <a href='http://www.ncbi.nlm.nih.gov/nuccore/FN436008'target="_blank">FN436008</a>
0
Robberbaron (robr)Commented:
you appear to have found what i was expecting.... a way to extract the text out of the control.  (which I may use myself sometime soon)

I thought it would be easier to get just the text part of the link but if it works, good!.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.