Search Results

Search found 4472 results on 179 pages for 'vb'.

Page 101/179 | < Previous Page | 97 98 99 100 101 102 103 104 105 106 107 108  | Next Page >

  • How can I create a generic constructor? (ie. BaseClass.FromXml(<param>)

    - by SofaKng
    I'm not sure how to describe this but I'm trying to create a base class that contains a shared (factory) function called FromXml. I want this function to instantiate an object of the proper type and then fill it via an XmlDocument. For example, let's say I have something like this: Public Class XmlObject Public Shared Function FromXml(ByVal source as XmlDocument) As XmlObject // <need code to create SPECIFIC TYPE of object and return it End Function End Class Public Class CustomObject Inherits XmlObject End Class I'd like to be able to do something like this: Dim myObject As CustomObject = CustomObject.FromXml(source) Is this possible?

    Read the article

  • Bind a WPF combobox and get selecteditem to a richtextbox

    - by Peter
    Hi, I am using a dataset on the server, in this dataset I have a datatable that calls a stored procedure and returns column names from three tables. I call this stored procedure using a web service. I manage to show all the column names in my combobox but when I want to click a button and insert selected column name into a richtextbox I get System.Data.DataRowView in the textbox instead. My code: 'the combobox 'if I don't have this textblock all the values are shown vertical instead of the normal horizontal lines 'the stored procedure SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE (TABLE_NAME = 'Customer') OR (TABLE_NAME = 'Invoices') OR (TABLE_NAME = 'Orders') 'the button Private Sub btnAddColumnNames_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnAddColumnNames.Click ' Add column names to the richtextbox Dim tr As New TextRange(rtbText.Selection.Start, rtbText.Selection.End) tr.Text = cboColumnNames.SelectedItem.ToString() rtbText.Focus() End Sub Any suggestions on how to get the selected text in the combobox to the richtextbox? Any help is appreciated.

    Read the article

  • Excel - referenced values via OleDB from .Net client

    - by ho
    I'm trying to read an Excel file (.xls, I think Excel 2003 compatible) via OleDB, but it fails to get the values for referenced fields. This is my current test code (please note, this is just part of the class): Private m_conn As OleDbConnection Public Sub New(ByVal fileName As String) Dim connString As String = String.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties=Excel 8.0;", fileName) m_conn = New OleDbConnection(connString) m_conn.Open() End Sub Public Sub GetSheet(ByVal sheet As String) Dim query As String = String.Format("SELECT * FROM [{0}]", sheet) Using cmd As OleDbCommand = m_conn.CreateCommand() cmd.CommandText = query Dim ds As New DataSet() Dim a As New OleDbDataAdapter(cmd) Using rdr As OleDbDataReader = cmd.ExecuteReader() While rdr.Read() Debug.WriteLine(rdr.Item(0).ToString()) End While End Using End Using End Sub But if the value is a reference (something like =+'MySheetName'!K37), I just get a DBNull from the call to rdr.Item(0). I can get around this by automating Excel instead, but would prefer not to have to use Excel automation so wondering if anyone knows how to do it.

    Read the article

  • Sales figures not displayed in form

    - by Brian Wilson
    Trying to calculate total sales for 5 items, 3 stores. Here's a s/s of what Im getting, along with my code. What am I missing/doing wrong? (p.s. It's not returning an error code in 'debug') Public Class Form1 Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click Dim ttlsales As Double 'set up array data Dim sales(,) As Integer = {{25, 64, 23, 45, 14}, {12, 82, 19, 34, 63}, {54, 22, 17, 43, 35}} Dim price() As Double = {12.0, 17.95, 95.0, 86.5, 78.0} 'mark totals Dim totals(2) As Double For store As Integer = 0 To 2 For item As Integer = 0 To 4 Next Next 'display output lstOut.Items.Add("Sales Per Store") For store As Integer = 0 To 2 lstOut.Items.Add(store + 1 & ":" & FormatCurrency(totals(store))) ttlsales += totals(store) Next lstOut.Items.Add("Total Sales: " & FormatCurrency(ttlsales)) End Sub End Class

    Read the article

  • Data adapter not filling my dataset

    - by Doug Ancil
    I have the following code: Imports System.Data.SqlClient Public Class Main Protected WithEvents DataGridView1 As DataGridView Dim instForm2 As New Exceptions Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles startpayrollButton.Click Dim ssql As String = "select MAX(payrolldate) AS [payrolldate], " & _ "dateadd(dd, ((datediff(dd, '17530107', MAX(payrolldate))/7)*7)+7, '17530107') AS [Sunday]" & _ "from dbo.payroll" & _ " where payrollran = 'no'" Dim oCmd As System.Data.SqlClient.SqlCommand Dim oDr As System.Data.SqlClient.SqlDataReader oCmd = New System.Data.SqlClient.SqlCommand Try With oCmd .Connection = New System.Data.SqlClient.SqlConnection("Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx") .Connection.Open() .CommandType = CommandType.Text .CommandText = ssql oDr = .ExecuteReader() End With If oDr.Read Then payperiodstartdate = oDr.GetDateTime(1) payperiodenddate = payperiodstartdate.AddSeconds(604799) Dim ButtonDialogResult As DialogResult ButtonDialogResult = MessageBox.Show(" The Next Payroll Start Date is: " & payperiodstartdate.ToString() & System.Environment.NewLine & " Through End Date: " & payperiodenddate.ToString()) If ButtonDialogResult = Windows.Forms.DialogResult.OK Then exceptionsButton.Enabled = True startpayrollButton.Enabled = False End If End If oDr.Close() oCmd.Connection.Close() Catch ex As Exception MessageBox.Show(ex.Message) oCmd.Connection.Close() End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click Dim connection As System.Data.SqlClient.SqlConnection Dim adapter As System.Data.SqlClient.SqlDataAdapter = New System.Data.SqlClient.SqlDataAdapter Dim connectionString As String = "Initial Catalog=mdr;Data Source=xxxxx;uid=xxxxx;password=xxxxx" Dim ds As New DataSet Dim _sql As String = "SELECT [Exceptions].Employeenumber,[Exceptions].exceptiondate, [Exceptions].starttime, [exceptions].endtime, [Exceptions].code, datediff(minute, starttime, endtime) as duration INTO scratchpad3" & _ " FROM Employees INNER JOIN Exceptions ON [Exceptions].EmployeeNumber = [Exceptions].Employeenumber" & _ " where [Exceptions].exceptiondate between @payperiodstartdate and @payperiodenddate" & _ " GROUP BY [Exceptions].Employeenumber, [Exceptions].Exceptiondate, [Exceptions].starttime, [exceptions].endtime," & _ " [Exceptions].code, [Exceptions].exceptiondate" connection = New SqlConnection(connectionString) connection.Open() Dim _CMD As SqlCommand = New SqlCommand(_sql, connection) _CMD.Parameters.AddWithValue("@payperiodstartdate", payperiodstartdate) _CMD.Parameters.AddWithValue("@payperiodenddate", payperiodenddate) adapter.SelectCommand = _CMD Try adapter.Fill(ds) If ds Is Nothing OrElse ds.Tables.Count = 0 OrElse ds.Tables(0).Rows.Count = 0 Then 'it's empty MessageBox.Show("There was no data for this time period. Press Ok to continue", "No Data") connection.Close() Exceptions.saveButton.Enabled = False Exceptions.Hide() Else connection.Close() End If Catch ex As Exception MessageBox.Show(ex.ToString) connection.Close() End Try Exceptions.Show() End Sub Private Sub payrollButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles payrollButton.Click Payrollfinal.Show() End Sub End Class and when I run my program and press this button Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exceptionsButton.Click I have my date range within a time that I know that my dataset should produce a result, but when I put a line break in my code here: adapter.Fill(ds) and look at it in debug, I show a table value of 0. If I run the same query that I have to produce these results in sql analyser, I see 1 result. Can someone see why my query on my form produces a different result than the sql analyser does? Also here is my schema for my two tables: Exceptions employeenumber varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS exceptiondate datetime no 8 yes (n/a) (n/a) NULL starttime datetime no 8 yes (n/a) (n/a) NULL endtime datetime no 8 yes (n/a) (n/a) NULL duration varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS code varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS approvedby varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS approved varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS time timestamp no 8 yes (n/a) (n/a) NULL employees employeenumber varchar no 50 no no no SQL_Latin1_General_CP1_CI_AS name varchar no 50 no no no SQL_Latin1_General_CP1_CI_AS initials varchar no 50 no no no SQL_Latin1_General_CP1_CI_AS loginname1 varchar no 50 yes no no SQL_Latin1_General_CP1_CI_AS

    Read the article

  • Array basics - Populating with loop

    - by madlan
    Hi, I'm looping through a zip file trying to add the file name of each file within. Is this the correct method? Dim ZipNameArray(?) Using zip As ZipFile = ZipFile.Read(ZipToUnpack) For Each file In zip ZipNameArray(?) = file .FileName Next End Using I do not know the array size until I start looping through the zip (To work out the number of files within). How do I increment the Array? file is not a number? (It's a ZipEntry)

    Read the article

  • how to populate different records in row of a Grid?

    - by ahmed
    Helo, I have a two Grid where I have to display some records from the table. The table consists of employee names ,manager names and their comments. Now on the first gird I am fetching data of employee names. Now on the second grid I have to display data of manager names and their comments. The data is on the same table. On show button of the first grid it shows all the employees. then on AdvWebGrid.ClickLink or any selected user on the first grid , i have to display the manager names and their comments on the second grid. How can I do that ? Hope my problem is clear?

    Read the article

  • How Do You Parse Column Data ?

    - by discwiz
    I am trying to parse a file generated by LGA Tracon that lists the position data for aircraft over a given time frame. The data of interest starts with TRACKING DATA and ends with SST and there are thousands of entries per file. The system generating the file, Common ARTS, is very rigid in its formatting and we can expect the column spacing to be consistent. Any help would be greatly appreciated. Thanks, Here is an image to preserve the exact formatting Here is a reduced text file. link text

    Read the article

  • Building A True Error Handler

    - by Kevin Pirnie
    I am trying to build an error handler for my desktop application. The code Is in the class ZipCM.ErrorManager listed below. What I am finding is that the outputted file is not giving me the correct info for the StackTrace. Here is how I am trying to use it: Try '... Some stuff here! Catch ex As Exception Dim objErr As New ZipCM.ErrorManager objErr.Except = ex objErr.Stack = New System.Diagnostics.StackTrace(True) objErr.Location = "Form: SelectSite (btn_SelectSite_Click)" objErr.ParseError() objErr = Nothing End Try Here is the class: Imports System.IO Namespace ZipCM Public Class ErrorManager Public Except As Exception Public Location As String Public Stack As System.Diagnostics.StackTrace Public Sub ParseError() Dim objFile As New StreamWriter(Common.BasePath & "error_" & FormatDateTime(DateTime.Today, DateFormat.ShortDate).ToString().Replace("\", "").Replace("/", "") & ".log", True) With objFile .WriteLine("-------------------------------------------------") .WriteLine("-------------------------------------------------") .WriteLine("An Error Occured At: " & DateTime.Now) .WriteLine("-------------------------------------------------") .WriteLine("LOCATION:") .WriteLine(Location) .WriteLine("-------------------------------------------------") .WriteLine("FILENAME:") .WriteLine(Stack.GetFrame(0).GetFileName()) .WriteLine("-------------------------------------------------") .WriteLine("LINE NUMBER:") .WriteLine(Stack.GetFrame(0).GetFileLineNumber()) .WriteLine("-------------------------------------------------") .WriteLine("SOURCE:") .WriteLine(Except.Source) .WriteLine("-------------------------------------------------") .WriteLine("MESSAGE:") .WriteLine(Except.Message) .WriteLine("-------------------------------------------------") .WriteLine("DATA:") .WriteLine(Except.Data.ToString()) End With objFile.Close() objFile = Nothing End Sub End Class End Namespace What is happenning is the .GetFileLineNumber() is getting the line number from 'objErr.Stack = New System.Diagnostics.StackTrace(True)' inside my Try..Catch block. In fact, it's the exact line number that is on. Any thoughts of what is going on here, and how I can catch the real line number the error is occuring on?

    Read the article

  • ASP.NET - DropDown DataBinding (Rebind?)

    - by Bob Fincheimer
    I have a drop down which has a method which binds data to it: dropDown.Items.Clear() dropDown.AppendDataBoundItems = True Select Case selType Case SelectionTypes.Empty dropDown.Items.Insert(0, New ListItem("", "")) Case SelectionTypes.Any dropDown.Items.Insert(0, New ListItem("ANY", "")) Case SelectionTypes.Select dropDown.Items.Insert(0, New ListItem("Select One", "")) End Select BindDropDown(val) The BindDropDown method simply sets the datasource, datakeyname, datavaluename, and then databinds the data. For a reason which I cannot avoid, I MUST call this method twice sometimes. When it is called twice, All of the databound items show up two times, but the top item (the one I manually insert) is there only once. Is ASP doing something wierd when i databind twice even though i clear the list between? Or does it have to do something with the viewstate/controlstate? EDIT__ The entire page, and this control has EnableViewState="false" EDIT___ The dropdown is inside a form view. After the selected value is set I have to rebind the dropdown just in case the selected value is not there [because it is an inactive user]. After this, the formview duplicates the databound items.

    Read the article

  • MS Access Bulk Insert exits app

    - by Brij
    In the web service, I have to bulk insert data in MS Access database. First, There was single complex Insert-Select query,There was no error but app exited after inserting some records. I have divided the query to make it simple and using linq to remove complexity of query. now I am inserting records using for loop. there are approx 10000 records. Again, same problem. I put a breakpoint after loop, but No hit. I have used try catch, but no error found. For Each item In lstSelDel Try qry = String.Format("insert into Table(Id,link,file1,file2,pID) values ({0},""{1}"",""{2}"",""{3}"",{4})", item.WebInfoID, item.Links, item.Name, item.pName, pDateID) DAL.ExecN(qry) Catch ex As Exception Throw ex End Try Next Public Shared Function ExecN(ByVal SQL As String) As Integer Dim ret As Integer = -1 Dim nowConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.AppDomain.CurrentDomain.BaseDirectory + "DataBase\\mydatabase.mdb;" Dim nowCon As System.Data.OleDb.OleDbConnection nowCon = New System.Data.OleDb.OleDbConnection(nowConString) Dim cmd As New OleDb.OleDbCommand(SQL, nowCon) nowCon.Open() ret = cmd.ExecuteNonQuery() nowCon.Close() nowCon.Dispose() cmd.Dispose() Return ret End Function After exiting app, I see w3wp.exe uses more than 50% of Memory. Any idea, What is going wrong? Is there any limitation of MS Access?

    Read the article

  • pdfSharp moving items on page

    - by Azza
    Hi, I am trying to move content in a pdf document using pdfSharp. We have a number of documents that are the same size i.e. 488x320mm, the content within these documents is always positioned relative to the top right of the document but varies in size i.e. 210x330mm, 240x350mm etc. What i need to do is 'find' the content block and move it from its current position to the centre of the sheet. Please help!

    Read the article

  • Splitcontainer, Make a fixed panel

    - by Marcx
    I have a splitcontainer with horizontal orientation. I want a fixed height for panel2 only during form resize, and let splitter resize panel2 Now I'm doing it this way, but I'm not satisfy because user notice the panel resize. Private Sub Form1_ResizeBegin(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Me.ResizeBegin spil = SplitContainer1.Height - SplitContainer1.SplitterDistance End Sub Private Sub Form1_ResizeEnd(ByVal sender As Object, ByVal e As System.EventArgs) _ Handles Me.ResizeEnd SplitContainer1.SplitterDistance = SplitContainer1.Height - spil End Sub Any ideas?

    Read the article

  • How to check if an SQL query executed without error in ASP?

    - by Sam
    Here's my code: if Request.Form("authorize") <> "" and request.form("delete") <> "true" then post_ids = Request.form("authorize") ids = split(post_ids, ",") For i = LBound(ids) to UBound(ids) sql = "update tbl_comments set authorized = 'true' where comment_id = " & ids(i) pageDB.execute(sql) Next message = "<div id=""succeed""><strong>Updated</strong>: Your comments have been approved.</div>" end if Instead of just setting "message" to the success message i'd like to do something along the lines of... if(pageDB.execute(sql) was succesful) then message = "<div id=""succeed""><strong>Updated</strong>: Your comments have been approved.</div>" else message = "<div id=""error""><strong>Error</strong>: Your comments have not been approved.</div>" end if

    Read the article

  • How do you pass a generic delegate argument to a method in .NET 2.0 - UPDATED

    - by Seth Spearman
    Hello, I have a class with a delegate declaration as follows... Public Class MyClass Public Delegate Function Getter(Of TResult)() As TResult ''#the following code works. Public Shared Sub MyMethod(ByVal g As Getter(Of Boolean)) ''#do stuff End Sub End Class However, I do not want to explicitly type the Getter delegate in the Method call. Why can I not declare the parameter as follows... ... (ByVal g As Getter(Of TResult)) Is there a way to do it? My end goal was to be able to set a delegate for property setters and getters in the called class. But my reading indicates you can't do that. So I put setter and getter methods in that class and then I want the calling class to set the delegate argument and then invoke. Is there a best practice for doing this. I realize in the above example that I can set set the delegate variable from the calling class...but I am trying to create a singleton with tight encapsulation. For the record, I can't use any of the new delegate types declared in .net35. Answers in C# are welcome. Any thoughts? Seth

    Read the article

  • ASP.Net Architecture Specific to Shared/Static functions

    - by Maxim Gershkovich
    Hello All, Could someone please advise in the context of a ASP.Net application is a shared/static function common to all users? If for example you have a function Public shared function GetStockByID(StockID as Guid) as Stock Is that function common to all current users of your application? Or is the shared function only specific to the current user and shared in the context of ONLY that current user? So more specifically my question is this, besides database concurrency issues such as table locking do I need to concern myself with threading issues in shared functions in an ASP.Net application? In my head; let’s say my application namespace is MyTestApplicationNamespace. Everytime a new user connects to my site a new instance of the MyTestApplicationNamespace is created and therefore all shared functions are common to that instance and user but NOT common across multiple users. Is this correct?

    Read the article

  • VB.NET looping through XML to store in singleton

    - by rockinthesixstring
    I'm having a problem with looping through an XML file and storing the value in a singleton My XML looks like this <values> <value></value> <value>$1</value> <value>$5,000</value> <value>$10,000</value> <value>$15,000</value> <value>$25,000</value> <value>$50,000</value> <value>$75,000</value> <value>$100,000</value> <value>$250,000</value> <value>$500,000</value> <value>$750,000</value> <value>$1,000,000</value> <value>$1,250,000</value> <value>$1,500,000</value> <value>$1,750,000</value> <value>$2,000,000</value> <value>$2,500,000</value> <value>$3,000,000</value> <value>$4,000,000</value> <value>$5,000,000</value> <value>$7,500,000</value> <value>$10,000,000</value> <value>$15,000,000</value> <value>$25,000,000</value> <value>$50,000,000</value> <value>$100,000,000</value> <value>$100,000,000+</value> </values> And my function looks like this Public Class LoadValues Private Shared SearchValuesInstance As List(Of SearchValues) = Nothing Public Shared ReadOnly Property LoadSearchValues As List(Of SearchValues) Get Dim sv As New List(Of SearchValues) If SearchValuesInstance Is Nothing Then Dim objDoc As XmlDocument = New XmlDataDocument Dim objRdr As XmlTextReader = New XmlTextReader(HttpContext.Current.Server.MapPath("~/App_Data/Search-Values.xml")) objRdr.Read() objDoc.Load(objRdr) Dim root As XmlElement = objDoc.DocumentElement Dim itemNodes As XmlNodeList = root.SelectNodes("/values") For Each n As XmlNode In itemNodes sv.Add(New SearchValues(n("@value").InnerText, n("@value").InnerText)) Next SearchValuesInstance = sv Else : sv = SearchValuesInstance End If Return sv End Get End Property End Class My problem is that I'm getting an object not set to an instance of an object on the sv.Add(New SearchValues(n("@value").InnerText, n("@value").InnerText)) line.

    Read the article

  • Inserting variables into a query string - it won't work!

    - by Jonesy
    Basically i have a query string that when i hardcode in the catalogue value its fine. when I try adding it via a variable it just doesn't pick it up. This works: Dim WaspConnection As New SqlConnection("Data Source=JURA;Initial Catalog=WaspTrackAsset_NROI;User id=" & ConfigurationManager.AppSettings("WASPDBUserName") & ";Password='" & ConfigurationManager.AppSettings("WASPDBPassword").ToString & "';") This doesn't: Public Sub GetWASPAcr() connection.Open() Dim dt As New DataTable() Dim username As String = HttpContext.Current.User.Identity.Name Dim sqlCmd As New SqlCommand("SELECT WASPDatabase FROM dbo.aspnet_Users WHERE UserName = '" & username & "'", connection) Dim sqlDa As New SqlDataAdapter(sqlCmd) sqlDa.Fill(dt) If dt.Rows.Count > 0 Then For i As Integer = 0 To dt.Rows.Count - 1 If dt.Rows(i)("WASPDatabase") Is DBNull.Value Then WASP = "" Else WASP = "WaspTrackAsset_" + dt.Rows(i)("WASPDatabase") End If Next End If connection.Close() End Sub Dim WaspConnection As New SqlConnection("Data Source=JURA;Initial Catalog=" & WASP & ";User id=" & ConfigurationManager.AppSettings("WASPDBUserName") & ";Password='" & ConfigurationManager.AppSettings("WASPDBPassword").ToString & "';") When I debug the catalog is empty in the query string but the WASP variable holds the value "WaspTrackAsset_NROI" Any idea's why? Cheers, jonesy

    Read the article

  • Accented character replacement for search then reinserted afterwards

    - by user314573
    Basically my issue is that users would like to search for a french word that has accented characters but without typing in the accented characters and then have the actual accented word appeared highlighted if found... So for example they would type in "declare" but in the result sets it would look like "déclare" and if found "déclare" would be highlighted. My first thought was to just simply replace the characters with a regex but then I remembered that I would need to re-insert the replaced characters after the search... I was thinking of then using some sort of character map that would track position and the character so that when the search was finshed I could put the result set back to the way it was. This seems a little brute force to me and I was wondering if anyone had a better alternative? I'm using Visual Studio 2005 with this app. Any advice would be much appreciated! Thanks

    Read the article

  • VS 2010 Entity Repository Error Class member EntityBase.id is unmapped.

    - by Steve
    In my project I have it set up so that all the tables in the DB has the property "id" and then I have the entity objects inherit from the EntityBase class using a repository pattern. I then set the inheritance modifier for "id" property in the dbml file o/r designer to "overrides" Public MustInherit Class EntityBase MustOverride Property id() As Integer End Class Public MustInherit Class RepositoryBase(Of T As EntityBase) Protected _Db As New DataClasses1DataContext Public Function GetById(ByVal Id As Integer) As T Return (From a In _Db.GetTable(Of T)() Where a.id = Id).SingleOrDefault End Function End Class Partial Public Class Entity1 Inherits EntityBase End Class Public Class TestRepository Inherits RepositoryBase(Of Entity1) End Class the line Return (From a In _Db.GetTable(Of T)() Where a.id = Id).SingleOrDefault however produces the error "Class member EntityBase.id is unmapped" when i use VS 2010 using the 4.0 framework but I never received that error with the old one. Any help would be greatly appreciated. Thanks in advance.

    Read the article

  • Export GridView to Excel (not working)

    - by Chiramisu
    I've spent the last two days trying to get some bloody data to export to Excel. After much research I determined that the best and most common way is using HttpResponse headers as shown in my code below. After stepping through countless times in debug mode, I have confirmed that the data is in fact there and both filtered and sorted the way I want it. However, it does not download as an Excel file, or do anything at all for that matter. I suspect this may have something to do with my UpdatePanel or perhaps the ImageButton not posting back properly, but I'm not sure. What am I doing wrong? Please help me to debug this issue. I will be eternally grateful. Thank you. :) Markup <asp:UpdatePanel ID="statusUpdatePanel" runat="server" UpdateMode="Conditional"> <Triggers> <asp:AsyncPostBackTrigger ControlID="btnExportXLS" EventName="Click" /> </Triggers> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" PageSize="10" AllowSorting="True" DataSourceID="GridView1SDS" DataKeyNames="ID"> </asp:GridView> <span><asp:ImageButton ID="btnExportXLS" runat="server" /></span> </ContentTemplate> </asp:UpdatePanel> Codebehind Protected Sub ExportToExcel() Handles btnExportXLS.Click Dim dt As New DataTable() Dim da As New SqlDataAdapter(SelectCommand, ConnectionString) da.Fill(dt) Dim gv As New GridView() gv.DataSource = dt gv.DataBind() Dim frm As HtmlForm = New HtmlForm() frm.Controls.Add(gv) Dim sw As New IO.StringWriter() Dim hw As New System.Web.UI.HtmlTextWriter(sw) Response.ContentType = "application/vnd.ms-excel" Response.AddHeader("content-disposition", "attachment;filename=Report.xls") Response.Charset = String.Empty gv.RenderControl(hw) Response.Write(sw.ToString()) Response.End() End Sub

    Read the article

< Previous Page | 97 98 99 100 101 102 103 104 105 106 107 108  | Next Page >