Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9007665
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:45:03+00:00 2026-06-16T01:45:03+00:00

We have a command button on an ASP.Net web form with a GridView that

  • 0

We have a command button on an ASP.Net web form with a GridView that the user sends the data displayed in the GridView as an email.

On this GridView is a “Select” command button that we would like to temporaraly remove from the GridView when the user clicks on an Image Button and have the button appear again when the email has been sent.

We want to remove the button because it shows up rendered in the email which we don’t want included in the email.

Can you tell me how to use coding in a code-behind file that will refresh the GridView without the button?

Here is some markup showing the button:

                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:Button 
                            ID="ButtonSelect" 
                            runat="server" 
                            CausesValidation="False" 
                            CommandName="Select" 
                            Text="Select Schedule Item Details" />
                    </ItemTemplate>

This is the coding we are using that sends out the email of the GridView:

Protected Sub ImageButtonEmailThisList_Click(sender As Object, e As ImageClickEventArgs)

    ' Get the rendered HTML.
    '-----------------------
    Dim SB As New StringBuilder()
    Dim SW As New StringWriter(SB)
    Dim htmlTW As New HtmlTextWriter(SW)

    ' Remove the select button for a short while.
    '--------------------------------------------

    GridViewSummary.RenderControl(htmlTW)

    ' Get the HTML into a string.
    ' This will be used in the body of the email report.
    '---------------------------------------------------
    Dim dataGridHTML As String = SB.ToString()
    Dim SmtpServer As New SmtpClient()

    ObjMailMessage = New MailMessage()

    Try
        With ObjMailMessage
            .To.Add(New MailAddress(TextBoxEmailRecipient.Text))
            .Subject = "Knowledge Academy Teacher's Schdule"
            .Body = dataGridHTML
            .IsBodyHtml = True
            .DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
        End With

        SmtpServer.Send(ObjMailMessage)

        LabelEmailMessage.Text = "<i>Email sent to " & TextBoxEmailRecipient.Text & "!</i>"

        ImageButtonEmailThisList.Visible = True

    Catch ex As Exception
        MsgBox(ex.ToString())

    Finally

        ' Refresh the GridView with select button back in place.
        '-------------------------------------------------------

    End Try

End Sub

The commented sections show where we would like to add the coding to hide and show the button again.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T01:45:04+00:00Added an answer on June 16, 2026 at 1:45 am

    Maybe you can hide the column :

    GridViewSummary.Columns(11).Visible = False
    

    And then :

    GridViewSummary.Columns(11).Visible = True
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using C# ASP.NET VS2010. I have a GridView including a select command button.
I have an asp.net ListView that is sortable. I have a button with a
I'm using ASP.NET 3.5. I made a form that when the user clicks a
say for instance I have the following button in a form in asp.net mvc
I have command button added in my asp.net grids. After performing an action using
I have a button on an ASP.Net page that will call Response.Redirect back to
I have a simple query tied to a command button that shows a summary
I have a button in my application which is bound to a command. This
So I have a background in ASP.NET where a button could have a click
So I have an ASP.NET grid view: <asp:GridView ID=gvReferences runat=server AutoGenerateColumns=False ShowHeader=False OnRowEditing=gvReferences_RowEditing OnRowDeleting=gvReferences_RowDeleting

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.