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 8407763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:27:22+00:00 2026-06-09T23:27:22+00:00

I am trying to hide the column Key or [0]. I am also trying

  • 0

I am trying to hide the column “Key” or [0]. I am also trying to set up check boxes in the below code that the end user can click/unclick. By default I set the checkbox to an unchecked state.

This code dgvPunchs.Columns[0].Hidden = true; is how I found out how to hide a column, but it errors out with the following error.

“Object reference not set to an instance of an object.”

Also currently the check boxes display, but the end user is not able to click them. I am baffled. Please help! 🙂

protected void GenerateSalaryPunchesTable()
        {
            this.dgvPunchs.Rows.Clear();

            string[] DateRange = this.cboPayPeriods.SelectedItem.Text.ToString().Replace(" ", "").Split('-');

            DataTable pDates = new DataTable();

            pDates.Columns.Add("Key");
            pDates.Columns.Add("Date", System.Type.GetType("System.DateTime")); // Date Cell
            pDates.Columns.Add("Worked", System.Type.GetType("System.Boolean")); //Worked CB
            pDates.Columns.Add("Vaction", System.Type.GetType("System.Boolean")); //Vacation CB
            pDates.Columns.Add("Sick", System.Type.GetType("System.Boolean")); //Sick CB
            pDates.Columns.Add("Holiday", System.Type.GetType("System.Boolean")); //Holiday CB
            pDates.Columns.Add("Error", System.Type.GetType("System.String")); //Error

            foreach (DataColumn col in pDates.Columns)
            {
                col.ReadOnly = false;
            }

            pDates.Columns["Key"].ColumnMapping = MappingType.Hidden;

            while (Convert.ToDateTime(DateRange[0]) <= Convert.ToDateTime(DateRange[1]))
            {
                if (Convert.ToDateTime(DateRange[0]).DayOfWeek != DayOfWeek.Saturday & Convert.ToDateTime(DateRange[0]).DayOfWeek != DayOfWeek.Sunday)
                {

                    DataRow nRow = pDates.NewRow();
                    nRow["Key"] = Convert.ToDateTime(DateRange[0].ToString()).ToShortDateString();
                    nRow["Date"]= Convert.ToDateTime(DateRange[0].ToString()).ToShortDateString();
                    nRow["Worked"] = 0;
                    nRow["Vaction"] = 0;
                    nRow["Sick"] = 0;
                    nRow["Holiday"] = 0;
                    nRow["Error"] = "";

                    pDates.Rows.Add(nRow);

                }

                DateRange[0] = Convert.ToDateTime(DateRange[0]).AddDays(1).ToShortDateString();
            }


            dgvPunchs.DataSource = pDates;
            dgvPunchs.DataBind();
            dgvPunchs.Columns[0].Hidden = true;
        }
  • 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-09T23:27:24+00:00Added an answer on June 9, 2026 at 11:27 pm

    You need to manually create the columns in WebDataGrid, if you don’t, just check columns.count, it will be = 0.
    So, you can do this in the init event of the WebDataGrid (before you set the WebDataGrid1.datasource and having WebDataGrid1.autogenertecolumns = false):

    Infragistics.Web.UI.GridControls.BoundDataField f;    
    Infragistics.Web.UI.GridControls.EditingColumnSetting columnSettingReadOnly;
    
    foreach (System.Data.DataColumn c in pDates.Columns)
                {
                        f = new Infragistics.Web.UI.GridControls.BoundDataField(true);
                        f.DataFieldName = c.ColumnName;
                        f.Key = c.ColumnName;
                        f.Header.Text = c.ColumnName;
                        WebDataGrid1.Columns.Add(f);
    // In order to set it as readonly:
    columnSettingReadOnly = New Infragistics.Web.UI.GridControls.EditingColumnSetting();
                    columnSettingReadOnly.ColumnKey = f.Key;
                    columnSettingReadOnly.ReadOnly = True;
                    WebDataGrid1.Behaviors.EditingCore.Behaviors.CellEditing.ColumnSettings.Add(columnSettingReadOnly);
                }
    

    Try this above and let us know.

    PS: not sure about the issue with column showing a checkbox doesn’t allowing you to check it…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table column I’m trying to expand and hide. jQuery seems to
I'm trying to write some code to Hide columns if the first 3 characters
I'm trying to hide the Settings area in CRM 2011 such that it is
I'm trying to hide a div in my template if the URL that is
I am trying to hide and display a UIView on BarButtonItem click. Priviously i
I'm trying to hide a date value in a column until it is needed,
Apologize for the length of the code. I'm trying to hide the three cells
I am trying to hide a table column of a table with jQuery but
I am trying to hide a button in a table column based on another
Im trying to hide a specific image in mouse over and display another image.

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.