GridView control exporting to Excel in Net 2.0

Well, I did my homework and found 33,868 references to issues with

the gridview control and Excel, none of which were close to whats happening

with my app. I have a Gridview control on my VB.NET main page and when I

right click on it the popup allows me to export to Excel just fine..5-6 columns,

less than 100 rows..when I do the same on another page I get an Excel error popup :

"This web query returned no data.."..both grids have a (Select) button in the 1st column.

The one that works is simply that...the one that doesn't has the Button.Text defined

as something else. The message is untraceable in Excel, as it has no error # displayed

with it in the popup. Tongue Tied   Should I search MSDN? I'm using VS2005 Pro, Excel 2002..

Thanks for helping..  Cool


9/1/2007 4:20:30 PM 72751 articles. 3 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 38


The one that works is simply that...the one that doesn't has the Button.

  I'm not quite sure what do you mean by this. Could you please post relevant code of these two pages? What's the different?


Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
9/3/2007 6:13:30 AM

Allen :

Thanks for it is.

==== This one works ======

*** code behind ***

    Protected Sub GridView2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView2.SelectedIndexChanged

        If intCI = 1 Then
            lblMsg.Text = "You must login as a member to buy this signal."
            'lblMsg.UpdateAfterCallBack = True
            '*** problem with the extender at this point..go to Login!!!
            Call CheckForBought_MoreRecent()
        End If

    End Sub

---HTML ---

        <ASP:panel ID="Grid" runat="server" style="left: 288px; position: absolute; top: 392px"
            EnableTheming="False" Height="171px" Width="472px" ScrollBars="Vertical">
            <ASP:GridView ID="GridView2" runat="server" Style="left: 0px; position: absolute;
                top: 0px" Width="456px" SelectedIndex="0"
                EnableTheming="False" Height="192px" 
                ShowHeader="False" AutoGenerateSelectButton="True" UseAccessibleHeader="False" >
                <SelectedRowStyle BackColor="#FFFF80" />
                <AlternatingRowStyle BackColor="#C0FFC0" />
                <RowStyle BackColor="White" />

==== This one doesn't work ======

*** code behind ***

    Protected Sub GridH_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridH.RowDataBound

        Dim row As GridViewRow = e.Row
        Dim selectCell As TableCell = row.Cells(0)

        If (selectCell.Controls.Count > 0) Then
            Dim selectControl As LinkButton = selectCell.Controls(0)
            If Not IsDBNull(selectControl) Then _
                selectControl.Text = dsConn.Tables("HS").Rows(e.Row.RowIndex).Item(0)
        End If

    End Sub
    Protected Sub GridH_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridH.SelectedIndexChanged
        Dim lngIndex As Long, intGrid As Integer

        blnBoughtOrMoreRecent = False
        lngIndex = GridH.SelectedIndex
        '*** needs to be here to check against
        txtSymbol.Text = dsConn.Tables("HS").Rows(lngIndex).Item(0)
        '*** if already bought, ignore the click
        If GridH.Rows(lngIndex).Cells(2).Text = "No " Then
            '*** a newer signal available?..
            With dsConn.Tables("Grid")
                If .Rows.Count > 0 Then
                    '*** search the grid from default page.
                    For intGrid = 0 To .Rows.Count - 1
                        strSymbol = .Rows(intGrid).Item(0)
                        dtSigDate = CDate(.Rows(intGrid).Item(3))
                        '*** yes, there is.
                        If strSymbol = txtSymbol.Text And dtSigDate > GridH.Rows(lngIndex).Cells(3).Text Then
                            blnBoughtOrMoreRecent = True
                            Exit For
                        End If
                    '*** if there was, show message box.
                    If blnBoughtOrMoreRecent Then
                        lblMsg.Text = "There is a more recent signal."
                        Exit Sub
                    End If
                End If
            End With

            txtCompany.Text = GridH.Rows(lngIndex).Cells(1).Text
            Call SelectQuerySQL( _
                "SELECT Exchange FROM SI WHERE Symbol ='" & txtSymbol.Text & "'", "S")
            txtMarket.Text = dsConn.Tables("S").Rows(0).Item(0)

            txtReliability.Text = GridH.Rows(lngIndex).Cells(6).Text
            txtDelDate.Text = GridH.Rows(lngIndex).Cells(3).Text
            txtUserID.Text = UserID.Text
            BuyItNameOnCard.Text = NameOnCard.Text
            txtCardNum.Text = CrCardNum.Text
            txtCardType.Text = cmbCardType.Text
            ExpirDate.Text = cmbExpMonth.Text & " / " & cmbExpYear.Text

            strSymbol = txtSymbol.Text
            strSymbolFor = txtCompany.Text
            dtSigDate = CDate(txtDelDate.Text)
            strCCN = txtCardNum.Text
            bytR = CByte(txtReliability.Text)
            strSignal = GridH.Rows(lngIndex).Cells(4).Text
            strMarket = txtMarket.Text
            '*** enc symbol and deliv date are used by OkbuyIt
            Call SelectQuerySQL( _
                "SELECT F9,F10 FROM Y WHERE F1 ='" & txtSymbol.Text & _
                "' AND DateValue(F4)='" & txtDelDate.Text & "' AND F8=" & intCI, "DT")
            strAHSymbol = dsConn.Tables("DT").Rows(0).Item(0)
            strAHF8 = dsConn.Tables("DT").Rows(0).Item(1)
        End If

    End Sub

---HTML ---

        <ASP:Panel ID="ADG" runat="server" style="left: 268px; position: absolute; top: 240px; z-index: 107;" Height="181px" Width="592px" ScrollBars="Vertical">
            <ASP:GridView ID="GridH" runat="server" EnableTheming="False"
                Font-Bold="True" Height="181px" PageSize="12" SelectedIndex="0" ShowHeader="False"
                Style="left: 0px; cursor: hand; position: absolute; top: 0px" TabIndex="19"
                Width="576px" AutoGenerateSelectButton="True" >
                <RowStyle Font-Bold="False" Font-Size="Smaller" BackColor="White" />
                <EditRowStyle HorizontalAlign="Left" VerticalAlign="Middle" />
                <SelectedRowStyle BackColor="#FFC080" />
                <PagerStyle Font-Bold="False" />
                <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Strikeout="False" />
                <AlternatingRowStyle BackColor="#80FF80" BorderColor="White" BorderStyle="None" />

Thanks for your help..Cool

9/3/2007 8:56:32 PM

Similar Artilces:

Master Details in two seperate GridView Controls
I am simply trying to have a list of people in the top grid control (works fine), then when selected have the second Grid Control show details for that person(not working). Here is what I am trying from the load event: Sub BindData() Dim myConnection As New MySql.Data.MySqlClient.MySqlConnection(System.Configuration.ConfigurationManager.AppSettings("ConnectionSql")) Dim strPersonSQL, strActSQL As String strPersonSQL = "select row_id, first_name, last_name, middle_initial, dsi_id, created, created_by, program_of_study, email from tbl_person" Dim myPerCommand As New MySqlClient.MySqlComm...

Datagrid(.net 1.1) to GridView(.net 2.0) and using the RowUpdating event how to extract the values from the controls.
Ok  This is the settings: I use a Viewgrid with only itemtemplate colums for example. <asp:TemplateField HeaderText="Test"><ItemTemplate><asp:Label id="LBL_Test" text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' runat="server" meta:resourcekey="LBL_TestResource1"></asp:Label></font></ItemTemplate> <EditItemTemplate><asp:TextBox ID="HDN_Test" Text='<%# DataBinder.Eval(Container.DataItem, "Test1") %>' Runat="server" meta:resourcekey="HDN_TestResource1" /></EditItemTemplate></asp:TemplateField>  The ...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0 #2
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! There are too many differences for one email - - from 1.0 to 1.1 (not a whole lot of real change, other than fixes, at least compared to 1.1 to 2.0) With 2.0, there were many new declarative controls, with many new ideas added in With 3.0, it's a superset of 2.0 - instead of replacing the installation completely, it just 'added on' new functionality - I would...

How to validate controls on a .NET 2.0 Web user Control
Hi Guys, (ASP.NET 2.0 / C#) I've looked thorugh every post on validating web user controls (and know about Pter Blum's Professional Validation and More package) - but can't seem to get my head around whre to start. I have a web user control, called wucICL.ascx on a we page called AddEditInvestment.aspx.  I would like to validate a couple of DropDownLists (ddlAccounts and ddlContacts) when the Insert and Update buttons are clicked on the AddEdit Investment page. The other controls on the AddEditInvestments page belong to a validation group called All Validators and the DropDownL...

Running server controls compiled for .NET 1.1 in .NET 2.0
Hello, I have tried upgrading our ASP.NET 1.1 application to .NET 2.0 by using Web Application Projects, and it works beautifully. We use several 3rd party controls that we bought for use in .NET 1.1 and these seem to just work in .NET 2.0, except that I get an intermittent problem with one of them. Should DLLs compiled using .NET 1.1 simply work, except if they access classes that have been removed from the framework in .NET 2.0? If I have both .NET 1.1 and .NET 2.0 present on the machine and the ASP.NET application is configured to run using .NET 2.0 and I have a DLL compiled using .NE...

Differences between .net 1, .net 1.1, .net 2.0 and .net 3.0
Hi, This seems to be a common question, but i havent got an answer yet:(Can, any one please explain me the differences between these versions.If you keep your feet firmly on the ground, you'll have trouble putting on your pants! Have a look into this links Rajawww.iGold.inDon't forget to click "Mark as Answer" on the post that helped you. This credits that m...

Help! Find row on which a button was pressed in the gridview control in .NET 2.0
How do you get the exact row (and column data from that row)  on which a button was pressed within a gridview. In .NET v1 using the datagrid control the followingconstruction was available:objArgs.Item.Cells(n).Textusing the datagrid DataGridCommandEventArgs parameter. choices in gridview are     Sub cmdBackTestSummary(ByVal objSender As Object, ByVal objArgs As GridViewCommandEventArgs) ' objArgs.commandname ' objargs.commandarguement ' objargs.commandsource     End Sub but no objArgs.Item.Cells(n) So how do you get the exact row (and c...

.Net 2.0 Web application using is unable to create object of another dll writen in C# .net 2.0
Hi, I habe created one web application using which is adding reference of dlls written in C# and .net 2.0. But whenever trying to create object of referencing dll, it is throwing error :Object reference does not set to an object. But, locally it is working fine,. In the server i have deployed the .aspx files and dll files in the bin. There were already an web.config in the server which is of .net 1.1. But checked it is retrieving value for that web.config correctly. Should i have to deply any other files and if not what can be the solution for this? Please help. Thanks, So...

Unable to access page controls from base class in .NET 2.0 Beta 2
Hello All, I have converted a large-ish project to VS2005 beta 2. It is going better than beta 1, but it's still a world of pain. The latest problem is that I can't seem to access page controls from within a base class. I'm sure I didn't get this on beta 1 so maybe something has changed. Or maybe I'm just tired and it'll seem obvious tomorrow (it's the end of the working day here in the UK). Anyway, my problem: I have a page, Administration.aspx, a code behind file Administration.aspx.cs (with an Administration class), and, in a seperate project, a class called AdminPage. ...

Custom Control in .NET 2.0
Hi Friend ,                    I have to create one custom control that have some JS Script file and one web Server Control .                   Plz guide me how to create custom control .  Rajeev Kumar TiwariMicrosoft Professional Hi, From your description, you are wondering how can you develop a custom control involved with some javascript files and some web server controls, right? For you first question, ac...

User controls in .net 2.0
I am using Visual Studio Express 2005.  I am trying to share user controls across applications using the "virtual directory trick" mentioned in the following articles :;EN-US;Q324785 This works in VS 2002, but it does not work in VS Express 2005.  Did MS purposefully eliminate this "trick" from .net 2.0, or am I just not implementing it right? Sharing user controls across applications is a perfectly natural thing to want to do.  It is one of the best ways ...

.net 2.0 data controls
I've just begun taking a look at .net 2.0 and am unsure if the new Data Controls will help with this problem.  I have a column in my database that stores a pdf filename, ex:  "pdfSample.pdf".  The directory is a variable within my project.  In my GridView, I need code that does the following: Private Sub ProductDetails_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs) Handles productdetail.RowDataBound&nbsp; Dim img As Image = CType(e.Row.FindControl("pdfImage"), Image) &nbsp; Dim pdfURL As String = "" 'Get the &qu...

Data Controls in .Net 2.0
What is the difference between GridView, DataLis, DetailsView & FormView.  Thanks & Regards Jai Shankar Here is how I  understand them. 1. Gridview displays multiple lists of data, and it supports paging, sorting, among other things2. DataList is pretty much the same, but you have more control over the html you generate over the gridview, but you won't get paging and sorting right out of the box. 3. DetailsView display one record (meaning one of the row in a gridview). Also, I believe you have limited control over the html it generates4. FormsView is just like detail...

Menu control in .net 2.0
I am creating my new app. in visual studio 2005 using 2.0 I created menu (with sub menu) on my header user control. Menu based on sitemapdatasource. Here is the code for menu and css file. <asp:menu id="menua" runat="server"                      datasourceid="SiteMapDataSource1"                     cssclass="menua"            &nb...

Web resources about - GridView control exporting to Excel in Net 2.0 -

Gas Exporting Countries Forum - Wikipedia, the free encyclopedia
The Gas Exporting Countries Forum ( GECF ) is an intergovernmental organization of 11 of the world's leading natural gas producers made up of ...

Facebook Updates Comments Box Plugin With Comment Exporting and Larger News Feed Stories
Facebook today released several updates to the newest version of its Comments Box social plugin for third party websites that will increase the ...

Lower dollar a boon for Canberra's wine exporting king
It may mean more expensive holidays for some, but one ACT registered company has enjoyed a profitable time thanks to the sharp fall in the Australian ...

Irish plant shut for exporting horsemeat
Sky News is Australia's leader in 24-hour news.

New online freight marketplace Cargohound aims to be the Uber of exporting
Cargo Hound wants to revolutionise the way goods are shipped from Australia.

Exporting the desperate; out of sight ... and mind
The boats have stopped, the point's been made, so why continue to treat those already ''here'' with such unconscionable cruelty?

Meat market: Andrew Forrest sees fortune in exporting beef to China
China is so desperate for good beef that Australian billionaire Andrew Forrest will be taking sample parcels of steak in his luggage on his next ...

Exporting carbon and hypocrisy: our big growth industry
Never mind our modest cuts to local emissions, new research shows Australia is heading into a carbon export boom.

Montreal men accused of illegally exporting railway equipment to Iran
Two Montreal men are charged with illegally exporting American-made railway equipment to Iran, violating Canada's Export and Import Permit Act ...

Lee Specialties Ltd. Charged With Exporting Prohibited Commodity To Iran
CALGARY - Putting the wrong address on a $15 shipment of synthetic rubber rings has cost an Alberta company $90,000 for violating legislation ...

Resources last updated: 12/11/2015 2:14:50 AM