This is a migrated thread and some comments may be shown as answers.
Set NullValue for each row of GridViewDateTimeColumn
1 Answer 9 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
özer asked on 02 Jul 2020, 03:04 PM


I take the table on a web page with C # and Selenium and show it in radGridView.
I add a GridViewCheckBoxColumn before the first column of each row, and I add GridViewDateTimeColumn and GridViewComboBoxColumn after the last column.
I want to equalize the initial value of the DatePicker object in GridViewDateTimeColumn to the value in column 7 of the row where it is located.

However, the initial value of DatePickers in all rows is equal to the value in the 7th column of the last row.

Here is my code:

01.public void FillRadGridView(List<IWebElement> rows, List<IWebElement> columns,  int rowCount, int columnCount, RadGridView rgv)
02.        {
04.            List<Visit> lst = new List<Visit>();
05.            Visit v = new Visit();
06.            for (int i = 0; i < rowCount; i++)
07.            {
08.                for (int j = 1; j <= columnCount; j++)
09.                {
11.                    v.Tckn = columns[1].Text;
12.                    v.AdSoyad = columns[2].Text;
13.                    v.Vaka = columns[3].Text;
14.                    v.RaporTakipNo = columns[4].Text;
15.                    v.RaporSiraNo = columns[5].Text;
16.                    v.RaporBaslamaTarihi = DateTime.Parse(columns[6].Text).ToShortDateString();
17.                    v.RaporBitisTarihi = DateTime.Parse(columns[7].Text).AddDays(-1).ToShortDateString();
18.                    v.IsBasiKontrolTarihi = DateTime.Parse(columns[7].Text).ToShortDateString();
19.                    v.CezaDurumu = columns[8].Text;
21.                }
22.                lst.Add(v);
23.            }
24.            rgv.Columns.Clear();
26.            GridViewCheckBoxColumn checkBoxColumn = new GridViewCheckBoxColumn();
27.            checkBoxColumn.DataType = typeof(int);
28.            checkBoxColumn.Name = "ColumnSelect";
29.            checkBoxColumn.FieldName = "select";
30.            checkBoxColumn.HeaderText = "Seç";
31.            rgv.Columns.Add(checkBoxColumn);
33.            rgv.DataSource = lst;
34.            AddColumnToRgv(rgv);
36.        }



1 Answer, 1 is accepted

Sort by
Dess | Tech Support Engineer, Principal
Telerik team
answered on 06 Jul 2020, 10:04 AM

Hello, özer,  

According to the provided information, it is not clear enough what is the Telerik product that you are currently using since this is the forum related to the Telerik UI for WinForms suite but you mentioned "web page".  I am providing an answer regarding the Telerik WinForms product. In case you are using another product, feel free to post your question in the relevant forum:

The provided information is also not enough to get full understanding of the precise case and the setup that you have. However, I will try to suggest a possible solution.

If you have an assigned value to a cell in GridViewDateTimeColumn, the cell is expected to show this value. Note that a GridViewDateTimeColumn offers the NullValue property. Thus, you specify what date value to be displayed within the cell if you have DBNull.Value or null

            GridViewDateTimeColumn col1 = new GridViewDateTimeColumn("Date1");
            col1.NullValue = new DateTime(2020, 1, 1);

            GridViewDateTimeColumn col2 = new GridViewDateTimeColumn("Date2"); 

            this.radGridView1.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;

            this.radGridView1.Rows.Add(DateTime.Now, DateTime.Now);
            this.radGridView1.Rows.Add(null, null);
            this.radGridView1.Rows.Add(DBNull.Value, DBNull.Value);
            this.radGridView1.Rows.Add(DateTime.Now.AddDays(-1), DateTime.Now.AddDays(-1));

If it is not the case or it doesn't fit your scenario, it would be greatly appreciated if you can provide more details about the exact goal that you are trying to achieve. Once we get better understanding of the precise case, we can about a suitable solution and provide further assistance. Thank you in advance for your cooperation.

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Dess | Tech Support Engineer, Sr.
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Asked by
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question