I tried to put the gridview in a form, but then when I fill it programically it says the Gridview2 does not exist.
I get this error:
GridView2' is not a member of 'SOWTimeReporting.CreateExcelSheet'
What am I doing wrong? I just want to export the contents of the gridview to Excel, which changes as the user picks different drop down listss to filter it.
DougP
I get this error:
GridView2' is not a member of 'SOWTimeReporting.CreateExcelSheet'
What am I doing wrong? I just want to export the contents of the gridview to Excel, which changes as the user picks different drop down listss to filter it.
Code:
---------------- This is the HTML markup ------------------
<asp:FormView ID="FormView1" runat="server">
<ItemTemplate>
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
</ItemTemplate>
</asp:FormView>
[code]
[code]
------------------------------ VB code behind ----------------------
the followin 3 linens are in the form load
Dim queryTrans As String = "Select blah blah blah
[bold][COLOR=blue]Me.GridView2[/color][/bold].DataSource = [bold][COLOR=orange]PopulateGridwithSQL(queryTrans)[/color][/bold]. ' Get blue Squiggly on these lines
[bold][COLOR=blue]Me.GridView2[/color][/bold].DataBind()
'--------- this is the function called above to fill the grid
Public Function [bold][COLOR=orange]PopulateGridwithSQL[/color][/bold]. ByVal SQLStatement As String)
Dim Conn As SqlConnection
'use ConnectionString from WEB config file
Dim connStr As String = ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString
Conn = New SqlConnection(connStr)
Conn.Open()
Dim daTrans As New SqlDataAdapter
Dim dtTrans As New DataTable
daTrans.SelectCommand = New SqlCommand(SQLStatement, Conn)
daTrans.Fill(dtTrans)
Return dtTrans
Conn = Nothing
End Function
DougP