This is a migrated thread and some comments may be shown as answers.

Complete gridview with empty rows

3 Answers 304 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Lookoum
Top achievements
Rank 1
Lookoum asked on 01 Dec 2011, 02:16 PM
Hi everybody,

I would like to know if it is possible to complete a gridview  with empty rows?

For example, I have a grid view which can contain 9 rows but I only have 3 items to show.
The bottom of my grid is empty and I'd prefer having empty rows than nothing!

How can I do this?

Thanks

Lookoum

3 Answers, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 02 Dec 2011, 05:02 PM
Hello Laffargue,

For this scenario you can use RadGridView in unbound mode. Set you number of rows and columns and fill only rows that must contain values. Here is a simple example:

radGridView1.RowCount = 9;
radGridView1.ColumnCount = 5;
for (int i = 0; i < 3; i++)
{
    for (int j = 0; j < radGridView1.ColumnCount; j++)
    {
        radGridView1.Rows[i].Cells[j].Value = "MyValue";
    }
     
}

I hope this helps. Let me know if you need further assistance.

Best wishes,
Julian Benkov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

0
Lookoum
Top achievements
Rank 1
answered on 05 Dec 2011, 04:46 PM
Hi Mr Benkov,

Thanks for your answer but my RadGridView is filled by my database.
I used the FiledName properties in order to bind values.
Isn't it posssible to complete the grid automatically?

I think maybe there's a problem when I group my data by a column.

I would like to complete my grid cause I use the alternatingrowscolors properties  (blue and gray) and I don't want to see some blank on the bottom of the grid if this one is not complete.

Thank you.

Lookoum

0
Julian Benkov
Telerik team
answered on 08 Dec 2011, 10:05 AM
Hello Laffargue,

I understand your requirements. The RadGridView control does not support this functionality - to mix bound and unbound rows to render alternating row colors. The solution in this situation is to add dummy empty rows in your data source, but the synchronization will be more complex if you apply sorting, filtering, grouping operations.

Do not hesitate to contact us if you have further questions or issues.

Regards,
Julian Benkov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
GridView
Asked by
Lookoum
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Lookoum
Top achievements
Rank 1
Share this question
or