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

Trying to delete table rows if they contain no data

1 Answer 239 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 10 Dec 2012, 05:53 PM
I have a Table used to display an Address.  Not every user fills in every field and at diplay time i'd like to just remove the Rows that have no data.

I did this so far

var recipientContact = from ro in recipientOrg.AsEnumerable()
                        join rc in _db.RecipientContacts
                       on ro.RecipientOrganizationID equals rc.RecipientOrganizationID
                        select new
                          {
                              OrgName = rc.RecipientOrganization.Name,
                               ContactName = rc.FirstName + " " + rc.Surname,
                               Address1 = rc.Address1,
                               Address2 = rc.Address2,
                               City = rc.City.CityName,
                               Province = rc.Province.NameEnglish,
                               Country = rc.Country.CountryName,
                               PostalCode = rc.PostalCode,
                               Fax = ro.FaxNumber,
                               Phone = ro.PhoneNumber
                        };
                table5.DataSource = recipientContact.ToList();
 
        private void table5_ItemDataBound(object sender, EventArgs eventArgs)
        {
 
 
 
        }

This works fine, what I was thinking was that I could, in the databound event, loop through the Rows and see which, if any had no contents and jest Delete It?

Not sure where to start there though.

1 Answer, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 13 Dec 2012, 01:50 PM
Hi Tim,

Deleting a table row/column programmatically is not that simple. You need to remove the underlying report items of that row as well. Additionally as the Table is data-driven, removing rows/columns is not correct and there is a much simpler method to prevent a certain table row from appearing. If you apply a filter to a row group which always evaluates to false, that will prevent the corresponding table row from appearing. If the row group is static (i.e. it has no grouping criteria specified) you need to make it dynamic first (e.g. by specifying a grouping criteria which groups by a constant value). This approach uses only group filters - no additional coding is involved at all.

Regards,
Steve
the Telerik team

HAPPY WITH REPORTING? Do you feel that it is fantastic? Or easy to use? Or better than Crystal Reports? Tell the world, and help fellow developers! Write a short review about Telerik Reporting and Telerik Report Designer in Visual Studio Gallery today!

Tags
General Discussions
Asked by
Tim
Top achievements
Rank 1
Answers by
Steve
Telerik team
Share this question
or