Windows Develop Bookmark and Share   
 index > Windows Forms Data Controls and Databinding > How to show a default text when no rows is bounded in a grid?
 

How to show a default text when no rows is bounded in a grid?

Hi All,

I have bounded a grid with some data. Now i need to show a text "No items bounded" when the grid doesn't have any rows to bind in it. I have tried this coding....

in VS 2005 grid_RowDataBound

if (grid.Rows.Count == 0)

{

lblStatus.Text = "No items found";

}

But this is not working.... Can anyone help me?

Regards,

Cbe

Cbe  Monday, January 08, 2007 7:18 AM

Hi,Cbe

By default, when you bind a DataGridView to a dataset like or datatable like datasource, and allow user to add new row, the row counting of the DataGridView would contain a "New Row", so when no items bound, the count is 1 instead of 0. You can count the rows in the datasource instead of the DataGridView.

Regards.

Zhi-Xin Ye  Wednesday, January 10, 2007 8:34 AM

Hi,Cbe

By default, when you bind a DataGridView to a dataset like or datatable like datasource, and allow user to add new row, the row counting of the DataGridView would contain a "New Row", so when no items bound, the count is 1 instead of 0. You can count the rows in the datasource instead of the DataGridView.

Regards.

Zhi-Xin Ye  Wednesday, January 10, 2007 8:34 AM

You can use google to search for other answers

Custom Search

More Threads

• Designer Error when setting BindingSource.Datasource = SomeOtherBindingSource
• how to add a new row to datagridview + bound text boxes et
• dataset.haschanges is not returning true
• How to run time grey out a value (read only) in property grid?
• In search for an enhanced list view
• Simple Data Binding to a CheckBox Control
• Can I access the label formatting function?
• To calculate a person's age by date, month and year in VB 2008
• DataGridView FullRowSelect and Keyboard shortcuts
• Cant Insert/Update data using DataGridView