Click here to Skip to main content
15,891,136 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Can not display Image Pin
Orcun Iyigun29-Mar-11 12:52
Orcun Iyigun29-Mar-11 12:52 
GeneralRe: Can not display Image Pin
Pete O'Hanlon29-Mar-11 18:57
mvePete O'Hanlon29-Mar-11 18:57 
QuestionGridview updateproblem - Oracle SQL Pin
√ensens29-Mar-11 5:25
√ensens29-Mar-11 5:25 
AnswerRe: Gridview updateproblem - Oracle SQL [modified] Pin
Wendelius29-Mar-11 7:12
mentorWendelius29-Mar-11 7:12 
GeneralRe: Gridview updateproblem - Oracle SQL Pin
√ensens3-Apr-11 23:22
√ensens3-Apr-11 23:22 
GeneralRe: Gridview updateproblem - Oracle SQL Pin
Wendelius4-Apr-11 10:25
mentorWendelius4-Apr-11 10:25 
Questionvertical image in embedded reportviewer [modified] Pin
gavindon29-Mar-11 4:10
gavindon29-Mar-11 4:10 
QuestionRemove Multiple Gridview Columns before Excel Export Pin
massaslayer29-Mar-11 2:35
massaslayer29-Mar-11 2:35 
Hello!

I'm trying to find a code to delete multiple columns because when you delete a column the next column takes his place so for example:

If you delete column 6 then column 7 becomes column six.

I tried the following code with an for loop & a while loop:

Dim field As DataControlField = gv.Columns(i)
gv.Columns.Remove(field)

&

gv.columns.removeat(i)

But same case that the column 7 becomes column 6

The variable removeColumns is an array with the column number that need to be deleted.
If wanted I can also provide the Header Names


Thanks a lot for anyone who can Help me!


Imports System.Data
Imports System.Configuration
Imports System.IO
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls


Public Class GridViewExportUtil
    Public Shared Sub Export(ByVal fileName As String, ByVal gv As GridView, ByVal removeColumns As Integer())
        HttpContext.Current.Response.Clear()
        HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fileName))
        HttpContext.Current.Response.ContentType = "application/ms-excel"

'Gridview column delete code should come here


        Using sw As New StringWriter()
            Using htw As New HtmlTextWriter(sw)
                '  Create a form to contain the grid
                Dim table As New Table()

                '  add the header row to the table
                If gv.HeaderRow IsNot Nothing Then
                    GridViewExportUtil.PrepareControlForExport(gv.HeaderRow)
                    table.Rows.Add(gv.HeaderRow)
                End If

                '  add each of the data rows to the table
                For Each row As GridViewRow In gv.Rows
                    GridViewExportUtil.PrepareControlForExport(row)
                    table.Rows.Add(row)
                Next

                '  add the footer row to the table
                If gv.FooterRow IsNot Nothing Then
                    GridViewExportUtil.PrepareControlForExport(gv.FooterRow)
                    table.Rows.Add(gv.FooterRow)
                End If

                '  render the table into the htmlwriter
                table.RenderControl(htw)

                '  render the htmlwriter into the response
                HttpContext.Current.Response.Write(sw.ToString())
                HttpContext.Current.Response.[End]()
            End Using
        End Using
    End Sub

QuestionTranscation Id+Paypal Pin
Ramkumar_S28-Mar-11 22:59
Ramkumar_S28-Mar-11 22:59 
AnswerRe: Transcation Id+Paypal Pin
Viral Upadhyay28-Mar-11 23:36
Viral Upadhyay28-Mar-11 23:36 
GeneralRe: Transcation Id+Paypal Pin
Ramkumar_S28-Mar-11 23:48
Ramkumar_S28-Mar-11 23:48 
AnswerRe: Transcation Id+Paypal Pin
Viral Upadhyay29-Mar-11 0:11
Viral Upadhyay29-Mar-11 0:11 
GeneralRe: Transcation Id+Paypal Pin
Ramkumar_S29-Mar-11 18:07
Ramkumar_S29-Mar-11 18:07 
QuestionAsp.net can play "Flash,video, Image, HTML" in one control? Pin
buffering8328-Mar-11 22:12
buffering8328-Mar-11 22:12 
AnswerRe: Asp.net can play "Flash,video, Image, HTML" in one control? Pin
Viral Upadhyay29-Mar-11 0:15
Viral Upadhyay29-Mar-11 0:15 
GeneralRe: Asp.net can play "Flash,video, Image, HTML" in one control? Pin
buffering8329-Mar-11 18:56
buffering8329-Mar-11 18:56 
QuestionUpdate Panel Issue Pin
Rameez Raja28-Mar-11 19:16
Rameez Raja28-Mar-11 19:16 
AnswerRe: Update Panel Issue Pin
thatraja28-Mar-11 20:04
professionalthatraja28-Mar-11 20:04 
GeneralRe: Update Panel Issue Pin
msqar29-Mar-11 2:37
msqar29-Mar-11 2:37 
AnswerRe: Update Panel Issue Pin
thatraja29-Mar-11 6:31
professionalthatraja29-Mar-11 6:31 
Questionpaypal Pin
Ramkumar_S28-Mar-11 15:38
Ramkumar_S28-Mar-11 15:38 
AnswerRe: paypal Pin
Abhijit Jana28-Mar-11 18:12
professionalAbhijit Jana28-Mar-11 18:12 
AnswerRe: paypal Pin
Rameez Raja28-Mar-11 19:30
Rameez Raja28-Mar-11 19:30 
GeneralRe: paypal Pin
thatraja28-Mar-11 19:42
professionalthatraja28-Mar-11 19:42 
Question403(The website declined to show this webpage) Error - WebConfig Authorization - Need to redirect to login Pin
De_Novice28-Mar-11 10:34
De_Novice28-Mar-11 10:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.