﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - Hide webgrid columns, defined in aspx, programmatically</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Hide-webgrid-columns-defined-in-aspx-programmatically/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Hide webgrid columns, defined in aspx, programmatically</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Hide-webgrid-columns-defined-in-aspx-programmatically/</link><pubDate>Sun, 26 May 2013 21:49:20 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>programmatically</category><category>hide</category><category>columns</category><category>aspx</category><category>markup</category><category>defines</category><description>&lt;p&gt;Hi Nikola,&lt;/p&gt;&lt;p&gt;Glad that you have solved your problem. However in my solution, there are many looping that happen for each column. If you have any further question, please don't hesitate to ask us.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Bernard&lt;/p&gt;</description></item><item><title>Hide webgrid columns, defined in aspx, programmatically</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Hide-webgrid-columns-defined-in-aspx-programmatically/</link><pubDate>Fri, 24 May 2013 04:14:28 GMT</pubDate><dc:creator>sinan.biondic@gmail.com</dc:creator><category>WebGrid</category><category>programmatically</category><category>hide</category><category>columns</category><category>aspx</category><category>markup</category><category>defines</category><description>&lt;p&gt;Hi Bernard,&lt;/p&gt;&lt;p&gt;thank you for your answer. It's funny that you should suggest this solution, since I had an epifany last night and thought of the same one. I already implemented this, and also thought this could be a performance issue, but now, since you proposed the same, I see that there is no smarter solution than this. Thank you again.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Nikola&lt;/p&gt;</description></item><item><title>Hide webgrid columns, defined in aspx, programmatically</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Hide-webgrid-columns-defined-in-aspx-programmatically/</link><pubDate>Thu, 23 May 2013 23:57:27 GMT</pubDate><dc:creator>bernard</dc:creator><category>WebGrid</category><category>programmatically</category><category>hide</category><category>columns</category><category>aspx</category><category>markup</category><category>defines</category><description>Hi Nikola,&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;I've made a sample regarding this scenario. It works, but as you can see there's much looping in this code that might cause low performance on WebGrid. Could you check on my sample and tell me if there's an error in my sample? I attach the sample here. Hope this helps.&lt;/div&gt;
&lt;div&gt;&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;Regards,&lt;br /&gt;Bernard&lt;/div&gt;</description></item><item><title>Hide webgrid columns, defined in aspx, programmatically</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Hide-webgrid-columns-defined-in-aspx-programmatically/</link><pubDate>Thu, 23 May 2013 06:03:40 GMT</pubDate><dc:creator>sinan.biondic@gmail.com</dc:creator><category>WebGrid</category><category>programmatically</category><category>hide</category><category>columns</category><category>aspx</category><category>markup</category><category>defines</category><description>&lt;p&gt;I have webgrid with all columns that can be contained in datasource, defined in markup. I don't know in advance which columns will come from database so I have to have them all. If I add them from code behind(which old version of application did) I'd have over 2000 lines of code, and now I have about 160 of them because that's how many possible columns exist. I am binding grid to datasource, and of course, if column defined in webgrid doesn't exist in datasource, databinding fails. So what I'm doing in PrepareDataBinding event is check for all columns in grid, if they have their pair in datasource. If not the column is removed from grid's column collection.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p /&gt;&lt;pre&gt;For Each col As WebGridColumn In gridZaposleni.RootTable.Columns
 colName = col.Name
 colMember = col.DataMember
 If Not dt.Columns.Contains(colMember) Then
 gridZaposleni.RootTable.Columns.Remove(col)
 End If
 Next&lt;/pre&gt;
&lt;p&gt; However, this doesn't work because the application fails as it comes to first column that doesn't have it's pair in datasource:&lt;/p&gt;
&lt;p&gt;"Can't find DataColumn with name 'Company' in the specified datasource".&lt;/p&gt;
&lt;p&gt;I also tried, instead of removing column, setting it's Bound and Visible properties to false. That works, but then I have the grid loading 160 columns, and when I have grouped col's, expanding them takes ages.&lt;/p&gt;
&lt;p&gt;There is option to bind grid dynamically to datasource and make it create all columns by itself, but this doesn't work for me because, some columns have formating on them like width, forecolor etc.&lt;/p&gt;
&lt;p&gt;My question is - why isn't my first option, with removing columns, working, and how to solve this problem?&lt;/p&gt;
&lt;p /&gt;</description></item></channel></rss>