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

  • SEARCH
  • Home
  • 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 3324070
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:22:40+00:00 2026-05-17T23:22:40+00:00

Is it possible to have a Checkbox that only shows up when Editing the

  • 0

Is it possible to have a Checkbox that only shows up when Editing the last row of a GridView?

I have tried something like this in the EditItemTemplate:

<asp:CheckBox ID="chkNextDay" runat="server" 
              ToolTip="Is it a next-day departure?"
              Enabled="true" 
              Checked='<%# DateTime.Parse(Eval("OutHour","{0:d}")).Date >
                           DateTime.Parse(Eval("InHour","{0:d}")).Date  %>'/>

Then on code-behind I tried hiding it for rows other than the last one like this:

protected void grvOutHour_RowEditing(object sender, GridViewEditEventArgs e)
        {
            GridView grvOutHour = (GridView)this.grvReport.Rows[grvReport.EditIndex].FindControl("grvOutHour");
            TextBox txtBox = (TextBox)grvOutHour.Rows[e.NewEditIndex].FindControl("txtEditOutHour");
            CheckBox nextDay = (CheckBox)grvOutHour.Rows[e.NewEditIndex].FindControl("chkNextDay");
            if (grvOutHour.Rows.Count-1 != e.NewEditIndex)
                nextDay.Visible = false;
        }

This ALMOST worked, but the checkbox kept showing for all fields, I think because the RowDataBound is called AFTER RowEditing again so it renders the whole thing again 🙁

Any suggestions?

Thanks,
EtonB.

  • 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-05-17T23:22:40+00:00Added an answer on May 17, 2026 at 11:22 pm

    Use RowDataBound instead…

    protected void grvOutHour_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowState == DataControlRowState.Edit)
        {
            GridView grid = (GridView)sender;
            CheckBox nextDay = (CheckBox)e.Row.FindControl("chkNextDay");
            nextDay.Visible = (e.Row.RowIndex == (grid.Rows.Count - 1));
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to have an argument parser like this? import argparse parser.add_argument('query2target.bam', help='A
is possible to have a separator between elements of a GridView? Thanks
Is it possible to have a free iPhone app that has say an initial
Is it possible to have unobtrusive validation to make a field required but only
I may have missed something obvious with WPF, but is it possible to create
I have the following models: Topic, UserProfile, UserSubscribedToTopic The last of these looks like
I have a checkbox that I want to bind to a subclass. The DataSource
I've got this issue. A template called checkbox that's called from while inside a
Basically what i would like to do is have a button which is only
I would like to programmatically fire an event on a spark checkbox. I have

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.