<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Tips &amp; Tricks</title><link>http://forums.asp.net/53.aspx</link><description>Cool code and exciting examples, provided by our members.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/3427276.aspx</link><pubDate>Sun, 27 Sep 2009 07:58:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:3427276</guid><dc:creator>jstranger</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/3427276.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=3427276</wfw:commentRss><description>&lt;p&gt;Sounds as if your issue may be the same or related to mine - but just to check..&lt;/p&gt;
&lt;p&gt;For several years I have used the relatively crude approach of declaring a GridView with a FooterTemplate on each column for inserts and an EmptyDataTemplate containing identical controls for inserting when there is no starting data. Then in code behind I test if the row count is 0 and if so find each control from the EmptyData template and if not do the same for the FooterRow. All works but very irritating.&lt;/p&gt;
&lt;p&gt;I have never been interested in any crude hack such as binding to an empty DataTable. So now I am trying to build a custom GridView using the approach to override CreateChildControls broadly as set out by CISCBrain with a few slight modifications (in addition I am also autogenerating command columns but these work OK so I have removed this processing from the code below).&lt;/p&gt;
&lt;p&gt;Protected Overrides Function CreateChildControls(ByVal dataSource As System.Collections.IEnumerable, ByVal dataBinding As Boolean) As Integer&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim numRows As Integer = MyBase.CreateChildControls(dataSource, dataBinding)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If numRows = 0 And (ShowHeaderWhenEmpty Or ShowFooterWhenEmpty) Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim tab As Table = Me.CreateChildTable()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim flds As DataControlField() = New DataControlField(Me.Columns.Count - 1) {}&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.Columns.CopyTo(flds, 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If ShowHeaderWhenEmpty Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _headerRow = MyBase.CreateRow(-1, -1, DataControlRowType.Header, DataControlRowState.Normal)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.InitializeRow(_headerRow, flds)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tab.Rows.Add(_headerRow)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnRowCreated(New GridViewRowEventArgs(_headerRow))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Insertable And ShowFooterWhenEmpty Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _footerRow = MyBase.CreateRow(-1, -1, DataControlRowType.Footer, DataControlRowState.Normal)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.InitializeRow(_footerRow, flds)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.ShowFooter = True&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tab.Rows.Add(_footerRow)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyBase.OnRowCreated(New GridViewRowEventArgs(_footerRow))&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.Controls.Clear()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.Controls.Add(tab)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return numRows&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Function&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;And I have the following properties:&lt;/p&gt;
&lt;p&gt;Protected _headerRow As GridViewRow = Nothing&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Overloads Overrides ReadOnly Property HeaderRow() As GridViewRow&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Not MyBase.HeaderRow Is Nothing Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return MyBase.HeaderRow&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return _headerRow&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Get&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Property&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Protected _footerRow As GridViewRow = Nothing&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Public Overloads Overrides ReadOnly Property FooterRow() As GridViewRow&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Get&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If Not MyBase.FooterRow Is Nothing Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return MyBase.FooterRow&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Return _footerRow&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End If&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Get&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; End Property&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;All this works and I can retrieve values from the controls in the footer row whether there is starting data or not.&lt;/p&gt;
&lt;p&gt;However, the problem I have is if the footer includes databound controls such as DropDownLists. In this case, I get an error that the Bind (or Eval) can only be used in the context of a databound control. This did not happen when I was using the EmptyDataTemplate for this purpose, so it would seem that somehow the footer row is not getting initialized properly. What do I need to do to ensure that the footer is properly initialized and databound? Does your code for maintaining viewstate on postbacks relate to my issue? Hopefully there is a solution which can be handled in the custom GridView class rather than requiring specific page code to initialize the footer - if the latter is the case then I am really back to square one as even the EmptyDataTemplate approach did this declaratively.&lt;/p&gt;
&lt;p&gt;Jon&lt;/p&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/2951765.aspx</link><pubDate>Thu, 19 Feb 2009 10:19:13 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2951765</guid><dc:creator>proturbo</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2951765.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=2951765</wfw:commentRss><description>&lt;p&gt;Great class! &lt;/p&gt;&lt;p&gt;I really can&amp;#39;t understand why MS did not implement the ability to display a footer/header when the grid is empty. &lt;/p&gt;&lt;p&gt;Anyway, I had problems with the GridViewEx when having input controls in the footer. They do not maintain viewstate on postbacks. Therefore I did a little tweak to solve that:&lt;/p&gt;&lt;p&gt;The ViewState is maintained because the footer is not the same footer as the original footer. As you can see in the code, there is newly created footer named _footerRow2. Therefore the viewstate will not be kept on postback. To fix this simply add a new readonly property exposing the _footerRow2. This way it is possible to find the controls in the new footer (using myGrid.FooterRowEmpty.findControls(&amp;quot;NameOfInputField&amp;quot;) and setting the values manually. If using the myGrid.FooterRow, you will find the controls, but they will of course not be visible.&lt;/p&gt;&lt;p&gt;Here is the code for the property: &lt;br /&gt;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;public virtual&lt;/span&gt; GridViewRow FooterRowEmpty
        {
            &lt;span class="kwd"&gt;get&lt;/span&gt;
            {
                &lt;span class="kwd"&gt;if&lt;/span&gt; (_footerRow2 == &lt;span class="kwd"&gt;null&lt;/span&gt;)
                {
                    EnsureChildControls();
                }
                &lt;span class="kwd"&gt;return&lt;/span&gt; _footerRow2;
            } 
        }&lt;/pre&gt;&lt;p&gt;And here is the usage on the footerrows:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;Private Sub&lt;/span&gt; Page_PreRender(&lt;span class="kwd"&gt;ByVal&lt;/span&gt; sender &lt;span class="kwd"&gt;As Object&lt;/span&gt;, &lt;span class="kwd"&gt;ByVal&lt;/span&gt; e &lt;span class="kwd"&gt;As&lt;/span&gt; System.EventArgs) &lt;span class="kwd"&gt;Handles MyBase&lt;/span&gt;.PreRender
        &lt;span class="kwd"&gt;If Not&lt;/span&gt; grdData &lt;span class="kwd"&gt;Is Nothing Then
            Dim&lt;/span&gt; footerRow &lt;span class="kwd"&gt;As&lt;/span&gt; GridViewRow = grdData.FooterRow
            &lt;span class="kwd"&gt;If&lt;/span&gt; grdData.Rows.Count = 0 &lt;span class="kwd"&gt;AndAlso Not&lt;/span&gt; grdData.FooterRowEmpty &lt;span class="kwd"&gt;Is Nothing Then&lt;/span&gt;
                footerRow = grdData.FooterRowEmpty
                LoadFilterValues(footerRow) &lt;span class="cmt"&gt;&amp;#39;Put values into the fields in the footer.&lt;/span&gt;
                SetDefaultButtonAndFocus(footerRow)
            &lt;span class="kwd"&gt;ElseIf Not&lt;/span&gt; footerRow &lt;span class="kwd"&gt;Is Nothing Then&lt;/span&gt;
                SetDefaultButtonAndFocus(footerRow)
            &lt;span class="kwd"&gt;End If
        End If
    End Sub&lt;/span&gt;&lt;/pre&gt;&amp;nbsp; This code will put the values back in the controls (LoadFilterValues) and set default button and focus (SetDefaultButtonAndFocus). You will have to write these yourself ;)&lt;br /&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/2425522.aspx</link><pubDate>Mon, 16 Jun 2008 11:12:36 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2425522</guid><dc:creator>rohit.rokade</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2425522.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=2425522</wfw:commentRss><description>&lt;p&gt;There is no need to do all these things if you are using Sqldatasource then just do the following thing,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;1) Insert new row in sqldatasource&lt;/p&gt;
&lt;p&gt;&amp;nbsp;2) and just after that set gridview&amp;#39;s edit index=0,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;So, it will open that newly added blank row in edit mode and thats all.&lt;/p&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1866324.aspx</link><pubDate>Mon, 20 Aug 2007 09:10:46 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1866324</guid><dc:creator>ViagraFalls</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1866324.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1866324</wfw:commentRss><description>&lt;p&gt;One of them is &lt;/p&gt;
&lt;p&gt;if (sortAttribute.IndexOf(e.SortExpression) &amp;gt; 0 || sortAttribute.Startswith(e.SortBLOCKED EXPRESSION&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Not sure what the other one is, as I&amp;#39;m at work, but it&amp;#39;s something starting with expression.&lt;/p&gt;&lt;pre class="coloredcode"&gt;&amp;nbsp;&lt;/pre&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1861237.aspx</link><pubDate>Thu, 16 Aug 2007 12:53:19 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1861237</guid><dc:creator>cruster</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1861237.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1861237</wfw:commentRss><description>When using this approach to get header &amp;amp; footer visible when there is no record, it works. Except for one thing. If I&amp;#39;ve got a Button in the footer, its Click event will not fire.
Any ideas?</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1860067.aspx</link><pubDate>Wed, 15 Aug 2007 20:43:29 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1860067</guid><dc:creator>Billyhole</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1860067.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1860067</wfw:commentRss><description>&lt;p&gt;Hey can you help me out?&amp;nbsp; What is the correction for the &amp;quot;BLOCKED EXPRESSION&amp;quot; stuff?&amp;nbsp; Thanks.&lt;/p&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1846109.aspx</link><pubDate>Tue, 07 Aug 2007 21:03:14 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1846109</guid><dc:creator>ViagraFalls</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1846109.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1846109</wfw:commentRss><description>&lt;p&gt;Doh. I think I just figured it out. Instead of creating it as a Web User Control, it helps if I create it as a Web Control Library.&lt;/p&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1846085.aspx</link><pubDate>Tue, 07 Aug 2007 20:49:16 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1846085</guid><dc:creator>ViagraFalls</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1846085.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1846085</wfw:commentRss><description>&lt;p&gt;Hmm. No matter what I tried, I could not get the code to work.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Here&amp;#39;s what I did:&lt;/p&gt;
&lt;p&gt;Started a new web project, created a folder called MyWebControls, and added a Web User Control to that. In the code-behind, I pasted the code code, and corrected where appropriate (The EXPRESSION BLOCKED).&lt;/p&gt;
&lt;p&gt;Got this:&lt;/p&gt;
&lt;p class="EC_MsoNormal"&gt;&lt;font face="Arial" size="2"&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Arial;"&gt;Error&amp;nbsp;1&amp;nbsp;Make sure that the class defined in this code file matches the &amp;#39;inherits&amp;#39; attribute, and that it extends the correct base class (e.g. Page or UserControl).&amp;nbsp;C:\Documents and Settings\..WebSite4\MyWebControls\GridViewExample.ascx.cs&amp;nbsp;1&amp;nbsp;33&amp;nbsp;C:\...\WebSite4\&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;I tried messing around in the ASPX file, by adding the MyWebControls namespace to the inherits bit:&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Arial;"&gt;&amp;lt;%&lt;font color="blue"&gt;&lt;span style="COLOR:blue;"&gt;@&lt;/span&gt;&lt;/font&gt; &lt;font color="#a31515"&gt;&lt;span style="COLOR:#a31515;"&gt;Control&lt;/span&gt;&lt;/font&gt; &lt;font color="red"&gt;&lt;span style="COLOR:red;"&gt;Language&lt;/span&gt;&lt;/font&gt;&lt;font color="blue"&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;C#&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font color="red"&gt;&lt;span style="COLOR:red;"&gt;AutoEventWireup&lt;/span&gt;&lt;/font&gt;&lt;font color="blue"&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;true&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font color="red"&gt;&lt;span style="COLOR:red;"&gt;CodeFile&lt;/span&gt;&lt;/font&gt;&lt;font color="blue"&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;GridViewExample.ascx.cs&amp;quot;&lt;/span&gt;&lt;/font&gt; &lt;font color="red"&gt;&lt;span style="COLOR:red;"&gt;Inherits&lt;/span&gt;&lt;/font&gt;&lt;font color="blue"&gt;&lt;span style="COLOR:blue;"&gt;=&amp;quot;MyWebControls_GridViewEx&amp;quot;&lt;/span&gt;&lt;/font&gt; %&amp;gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Arial;"&gt;At times I got this error:&lt;/span&gt;&lt;/p&gt;&lt;span style="FONT-SIZE:10pt;FONT-FAMILY:Arial;"&gt;
&lt;p class="EC_MsoNormal"&gt;&lt;font face="Arial" size="3"&gt;&lt;span style="FONT-SIZE:12pt;FONT-FAMILY:Arial;"&gt;Missing partial modifier on declaration of type &amp;#39;GridViewExample&amp;#39;; another partial declaration of this type exists&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="EC_MsoNormal"&gt;&lt;font face="Arial" size="3"&gt;&lt;span style="FONT-SIZE:12pt;FONT-FAMILY:Arial;"&gt;Could anyone try to either give me a more detailed description of steps to take, or just specifying where I went wrong? It&amp;#39;s been some time since I messed with ASP.NET, and I probably am overlooking something real easy. However, I have spent quite a bit of time on this already, and am hoping someone can give me a proper kick in the right direction. &lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="EC_MsoNormal"&gt;&lt;font face="Arial" size="3"&gt;&lt;span style="FONT-SIZE:12pt;FONT-FAMILY:Arial;"&gt;Thanks!&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p class="EC_MsoNormal"&gt;&lt;font face="Arial" size="3"&gt;&lt;span style="FONT-SIZE:12pt;FONT-FAMILY:Arial;"&gt;Peter&lt;/span&gt;&lt;/font&gt;&lt;/p&gt;&lt;/span&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1844769.aspx</link><pubDate>Tue, 07 Aug 2007 09:23:06 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1844769</guid><dc:creator>ViagraFalls</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1844769.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1844769</wfw:commentRss><description>&lt;p&gt;The line should be:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:yellow;"&gt;if&lt;/span&gt;&lt;/span&gt; (&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:cyan;"&gt;&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:cyan;"&gt;sortAttribute&lt;/span&gt;&lt;/span&gt;.&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:fuchsia;"&gt;IndexOf&lt;/span&gt;(&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:chartreuse;"&gt;e&lt;/span&gt;.&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:dodgerblue;"&gt;SortExpression&lt;/span&gt;) &amp;gt; &lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:yellow;"&gt;0&lt;/span&gt; || &lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:cyan;"&gt;&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:cyan;"&gt;sortAttribute&lt;/span&gt;&lt;/span&gt;.&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:fuchsia;"&gt;StartsWith&lt;/span&gt;(&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:chartreuse;"&gt;e&lt;/span&gt;.&lt;span id="google-navclient-hilite" style="COLOR:black;BACKGROUND-COLOR:dodgerblue;"&gt;SortExpression&lt;/span&gt;))
&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1561739.aspx</link><pubDate>Fri, 02 Feb 2007 21:38:20 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1561739</guid><dc:creator>hercules</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1561739.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1561739</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;e.SortBLOCKED EXPRESSION is undefined, it does not seem to come with the GridViewEventArgs,&lt;/p&gt;
&lt;p&gt;let me know what the space stands for in the middle or if a function or property is missing.&lt;/p&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1471262.aspx</link><pubDate>Mon, 20 Nov 2006 17:10:11 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1471262</guid><dc:creator>deur_h</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1471262.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1471262</wfw:commentRss><description>&lt;p&gt;Hi,&lt;/p&gt;&lt;p&gt;I've used part of this customcontrol in the past to make a
footerrow
with insert functionality display/work when the gridview is empty. This
has always worked great. Buttons and textboxes in the footer cuold
always be used normaly when an empty gridview was encountered.&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;Now I've got some search functionalty
embedded in the header and I'm using this customcontrol to show the
gridview when it is empty.&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;This time it's
not working though.&lt;/p&gt;&lt;p&gt;When an empty gridview
is returned after a search has been done, the searchbutton and
textboxes are shown. The sort-links returned by the GetHeader are not
however. It seems the header never gets initialized properly when a
search doesn't have any results. When a new search is performed after
an empty search, a postback occurs, but the RowCommand is never called.&lt;/p&gt;&lt;p&gt;I've found that the properties HeaderText and SortExpression of the
templatefield are not used when the templatefield contains a
HeaderTemplate. Therefor the build-in functionality of sorting could
not be used. The GetHeader function is for creating the sort-link in
the header.&lt;/p&gt;&lt;p&gt;Because
the search-textboxes are within the gridview, they do not automatically
persist their value during postbacks. I've come up with a way to
dynamically build and fill the filter parameters and expression and use
this to persist (re-fill) the search fields.&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;I'm using caching and filterparameters to fill and search the data in the gridview.&lt;/p&gt;&lt;p&gt;My Code:&amp;nbsp;&lt;/p&gt;
&lt;pre class="coloredcode"&gt;&lt;span class="kwd"&gt;protected override int&lt;/span&gt; CreateChildControls:&lt;br /&gt;Same as above (minus FreezeHeader, I'm using only the ShowWhenEmpty functionality)&lt;/pre&gt;&lt;pre class="coloredcode"&gt;SelectMethod (because of caching only called when necessary):&lt;br /&gt;public DataSet gvOrderList_Select(string sort)&lt;br /&gt;        {&lt;br /&gt;            string sql = "SELECT O.*, OS.Status AS StatusNaam, K.Achternaam FROM (ORDER O LEFT JOIN OrderStatus OS ON O.Status = OS.Id) LEFT JOIN Klant K ON O.KlantId = K.Id";&lt;br /&gt;&lt;br /&gt;            if (!string.IsNullOrEmpty(sort))&lt;br /&gt;            {&lt;br /&gt;                if (sort.Contains("IngangsDatum"))&lt;br /&gt;                    sort = sort.Replace("IngangsDatum", "O.IngangsDatum");&lt;br /&gt;                if (sort.Contains("Status"))&lt;br /&gt;                    sort = sort.Replace("Status", "O.Status");&lt;br /&gt;                sql += " ORDER BY " + sort + ";";&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;                sql += " ORDER BY O.IngangsDatum DESC;";&lt;br /&gt;&lt;br /&gt;            DataSet ds = db.Select(sql);&lt;br /&gt;&lt;br /&gt;            HttpContext.Current.Cache["CacheodsOrderList"] = ds;&lt;br /&gt;&lt;br /&gt;            return ds;&lt;br /&gt;        } &lt;br /&gt;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;OnRowCommand:&lt;br /&gt;protected void gvOrderList_RowCommand(object sender, GridViewCommandEventArgs e)&lt;br /&gt;    {&lt;br /&gt;        switch (e.CommandName)&lt;br /&gt;        {&lt;br /&gt;            case "new":&lt;br /&gt;                break;&lt;br /&gt;&lt;br /&gt;            case "edit":&lt;br /&gt;                break;&lt;br /&gt;&lt;br /&gt;            case "del":&lt;br /&gt;                break;&lt;br /&gt;&lt;br /&gt;            case "search":&lt;br /&gt;                string search;&lt;br /&gt;&lt;br /&gt;                odsOrderList.FilterParameters.Clear();&lt;br /&gt;&lt;br /&gt;                search = ((TextBox)gvOrderList.HeaderRow.FindControl("tbSearchOrdernummer")).Text;&lt;br /&gt;                if (!string.IsNullOrEmpty(search))&lt;br /&gt;                    odsOrderList.FilterParameters.Add("Ordernummer", search);&lt;br /&gt;                search = ((TextBox)gvOrderList.HeaderRow.FindControl("tbSearchDatumVan")).Text;&lt;br /&gt;                if (!string.IsNullOrEmpty(search))&lt;br /&gt;                    odsOrderList.FilterParameters.Add("DatumVan", TypeCode.DateTime, search);&lt;br /&gt;                search = ((TextBox)gvOrderList.HeaderRow.FindControl("tbSearchDatumTot")).Text;&lt;br /&gt;                if (!string.IsNullOrEmpty(search))&lt;br /&gt;                    odsOrderList.FilterParameters.Add("DatumTot", TypeCode.DateTime, search);&lt;br /&gt;                search = ((TextBox)gvOrderList.HeaderRow.FindControl("tbSearchAchternaam")).Text;&lt;br /&gt;                if (!string.IsNullOrEmpty(search))&lt;br /&gt;                    odsOrderList.FilterParameters.Add("Achternaam", search);&lt;br /&gt;                search = ((DropDownList)gvOrderList.HeaderRow.FindControl("ddlSearchStatus")).SelectedValue;&lt;br /&gt;                if (!string.IsNullOrEmpty(search))&lt;br /&gt;                    odsOrderList.FilterParameters.Add("Status", TypeCode.Int32, search);&lt;br /&gt;&lt;br /&gt;                BuildFilterBLOCKED EXPRESSION;&lt;br /&gt;&lt;br /&gt;                break;&lt;br /&gt;&lt;br /&gt;            default:&lt;br /&gt;                break;&lt;br /&gt;        }&lt;/pre&gt;&lt;pre class="coloredcode"&gt;OnDataBound:&lt;br /&gt;protected void gvOrderList_DataBound(object sender, EventArgs e)&lt;br /&gt;    {&lt;br /&gt;        BuildFilterBLOCKED EXPRESSION;&lt;br /&gt;    }&lt;/pre&gt;&lt;pre class="coloredcode"&gt;GetHeader:&lt;br /&gt;protectedstring GetHeader(string HeaderText, string SortExpression)&lt;br /&gt;    {&lt;br /&gt;        return "&amp;lt;a href=\"javascript:__doPostBack('" + gvOrderList.UniqueID + "','Sort$" + SortExpression + "')\"&amp;gt;&amp;lt;font class=\"titel\"&amp;gt;" + HeaderText + "&amp;lt;/font&amp;gt;&amp;lt;/a&amp;gt;";&lt;br /&gt;    }&lt;/pre&gt;&lt;pre class="coloredcode"&gt;BuildFilterExpression:&lt;br /&gt;protected void BuildFilterBLOCKED EXPRESSION&lt;br /&gt;    {&lt;br /&gt;        if (odsOrderList.FilterParameters.Count &amp;gt; 0)&lt;br /&gt;        {&lt;br /&gt;            StringBuilder sb = new StringBuilder();&lt;br /&gt;            for (int i = 0; i &amp;lt; odsOrderList.FilterParameters.Count; ++i)&lt;br /&gt;            {&lt;br /&gt;                switch (odsOrderList.FilterParameters[i].Name)&lt;br /&gt;                {&lt;br /&gt;                    case "Ordernummer":&lt;br /&gt;                        ((TextBox)gvOrderList.HeaderRow.FindControl("tbSearchOrdernummer")).Text = odsOrderList.FilterParameters["Ordernummer"].DefaultValue;&lt;br /&gt;                        sb.Append("Ordernummer LIKE '{" + i.ToString() + "}%' AND ");&lt;br /&gt;                        break;&lt;br /&gt;                    case "DatumVan":&lt;br /&gt;                        ((TextBox)gvOrderList.HeaderRow.FindControl("tbSearchDatumVan")).Text = odsOrderList.FilterParameters["DatumVan"].DefaultValue;&lt;br /&gt;                        sb.Append("IngangsDatum &amp;gt;= #{" + i.ToString() + "}# AND ");&lt;br /&gt;                        break;&lt;br /&gt;                    case "DatumTot":&lt;br /&gt;                        ((TextBox)gvOrderList.HeaderRow.FindControl("tbSearchDatumTot")).Text = odsOrderList.FilterParameters["DatumTot"].DefaultValue;&lt;br /&gt;                        sb.Append("IngangsDatum &amp;lt;= #{" + i.ToString() + "}# AND ");&lt;br /&gt;                        break;&lt;br /&gt;                    case "Achternaam":&lt;br /&gt;                        ((TextBox)gvOrderList.HeaderRow.FindControl("tbSearchAchternaam")).Text = odsOrderList.FilterParameters["Achternaam"].DefaultValue;&lt;br /&gt;                        sb.Append("Achternaam LIKE '{" + i.ToString() + "}%' AND ");&lt;br /&gt;                        break;&lt;br /&gt;                    case "Status":&lt;br /&gt;                        ((DropDownList)gvOrderList.HeaderRow.FindControl("ddlSearchStatus")).SelectedIndex = Convert.ToInt32(odsOrderList.FilterParameters["Status"].DefaultValue);&lt;br /&gt;                        sb.Append("Status = {" + i.ToString() + "} AND ");&lt;br /&gt;                        break;&lt;br /&gt;                    default:&lt;br /&gt;                        break;&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            odsOrderList.FilterExpression = (sb.Remove(sb.Length - 5, 5)).ToString();&lt;br /&gt;        }&lt;br /&gt;    } &lt;br /&gt;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;Gridview:&lt;br /&gt;&amp;lt;CustomControls:EmptyGridView ID="gvOrderList" runat="server" DataSourceID="odsOrderList" AllowSorting="true" AllowPaging="true" PageSize="10" PagerSettings-Position="Top" AutoGenerateColumns="false" ShowFooter="true" ShowHeader="true" DataKeyNames="Id" OnDataBound="gvOrderList_DataBound" OnRowCommand="gvOrderList_RowCommand" EmptyDataText="NIEUW - Geen orders" EnableViewState="false"&amp;gt;&lt;br /&gt;	&amp;lt;Columns&amp;gt;&lt;br /&gt;		&amp;lt;asp:TemplateField&amp;gt;&lt;br /&gt;			&amp;lt;HeaderTemplate&amp;gt;&lt;br /&gt;				&amp;lt;asp:Button ID="btnGVSearch" runat="server" CommandName="search" TabIndex="6" Text="Zoek" CssClass="Teksten" /&amp;gt;&lt;br /&gt;			&amp;lt;/HeaderTemplate&amp;gt;&lt;br /&gt;			&amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;				&amp;lt;asp:ImageButton ID="ibtnEdit" runat="server" CommandName="edit" CommandArgument='&amp;lt;%# Eval("Id") %&amp;gt;' ImageUrl="~/images/edit.gif" /&amp;gt;&amp;amp;nbsp;&amp;lt;asp:ImageButton ID="ibtnDel" runat="server" CommandName="del" CommandArgument='&amp;lt;%# Eval("Id") %&amp;gt;' OnClientClick="return confirm('Weet u zeker dat u deze order wilt verwijderen?')" ImageUrl="~/images/del.gif" /&amp;gt;&lt;br /&gt;			&amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;			&amp;lt;FooterTemplate&amp;gt;&lt;br /&gt;				&amp;lt;hr width="100%" /&amp;gt;&lt;br /&gt;			&amp;lt;/FooterTemplate&amp;gt;&lt;br /&gt;			&amp;lt;HeaderStyle HorizontalAlign="Left" VerticalAlign="Bottom" /&amp;gt;&lt;br /&gt;			&amp;lt;ItemStyle Width="75" HorizontalAlign="Left" VerticalAlign="Top" /&amp;gt;&lt;br /&gt;		&amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;		&amp;lt;asp:TemplateField&amp;gt;&lt;br /&gt;			&amp;lt;HeaderTemplate&amp;gt;&lt;br /&gt;				&amp;lt;%# GetHeader("Code", "Ordernummer") %&amp;gt;&lt;br /&gt;				&amp;lt;br /&amp;gt;&lt;br /&gt;				&amp;lt;asp:TextBox ID="tbSearchOrdernummer" runat="server" TabIndex="1" /&amp;gt;&lt;br /&gt;			&amp;lt;/HeaderTemplate&amp;gt;&lt;br /&gt;			&amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;				&amp;lt;%# Eval("Ordernummer") %&amp;gt;&lt;br /&gt;			&amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;			&amp;lt;HeaderStyle HorizontalAlign="Left" VerticalAlign="Top" /&amp;gt;&lt;br /&gt;			&amp;lt;ItemStyle HorizontalAlign="Left" VerticalAlign="Top" /&amp;gt;&lt;br /&gt;		&amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;		...&lt;br /&gt;		SOME MORE TEMPLATEFIELDS&lt;br /&gt;		...&lt;br /&gt;	&amp;lt;/Columns&amp;gt;&lt;br /&gt;&amp;lt;/CustomControls:EmptyGridView&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;asp:ObjectDataSource ID="odsOrderList" runat="server"&lt;br /&gt;TypeName="ObjectDataSources.odsOrderList"&lt;br /&gt;EnableCaching="true"&lt;br /&gt;CacheKeyDependency="CacheodsOrderList"&lt;br /&gt;SelectMethod="gvOrderList_Select"&lt;br /&gt;SortParameterName="sort"&lt;br /&gt;&amp;gt;&lt;br /&gt;&amp;lt;/asp:ObjectDataSource&amp;gt;&lt;/pre&gt;&lt;pre class="coloredcode"&gt;Any light you could shed on this would be greatly appreciated.&lt;/pre&gt;&lt;pre class="coloredcode"&gt;H. Deur&amp;nbsp;&lt;/pre&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1434025.aspx</link><pubDate>Thu, 19 Oct 2006 12:29:21 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1434025</guid><dc:creator>lc_</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1434025.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1434025</wfw:commentRss><description>&lt;p&gt;Hi there,&lt;/p&gt;&lt;p&gt;&amp;nbsp;I think you would be more comfortable with a solution like&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;strong id="1"&gt;1    &lt;/strong&gt;&lt;span class="cmt"&gt;//create the empty row&lt;/span&gt;
&lt;strong id="2"&gt;2    &lt;/strong&gt;GridViewRow emptyRow = &lt;span class="kwd"&gt;new&lt;/span&gt; GridViewRow(-1, -1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);
&lt;strong id="3"&gt;3    &lt;/strong&gt;&lt;span class="cmt"&gt;//add row to table&lt;/span&gt;
&lt;strong id="4"&gt;4    &lt;/strong&gt;tbl.Rows.Add(emptyRow);
&lt;strong id="5"&gt;5    &lt;/strong&gt;&lt;span class="cmt"&gt;//initialize row&lt;/span&gt;
&lt;strong id="6"&gt;6    &lt;/strong&gt;InitializeRow(emptyRow, fields);&lt;/pre&gt;&lt;pre class="coloredcode"&gt;This way you could use the standard methods of the GridView without having to rewrite everything.&lt;/pre&gt;&lt;pre class="coloredcode"&gt;Additionaly I came up with one problem concerning the line&lt;/pre&gt;&lt;pre class="coloredcode"&gt;&amp;nbsp;&lt;pre class="coloredcode"&gt;&lt;strong id="1"&gt;1    &lt;/strong&gt;Table table = &lt;span class="kwd"&gt;new&lt;/span&gt; Table();
&lt;strong id="2"&gt;2    &lt;/strong&gt;table.ID = &lt;span class="kwd"&gt;this&lt;/span&gt;.ID;
&lt;/pre&gt;&amp;nbsp;
&lt;/pre&gt;&lt;p&gt;&amp;nbsp;I wouldn&amp;#39;t do that, because this changes the IDs of the controls within the grid. The method of the GridView (CreateChildControls) creates the table as &amp;quot;ctl00&amp;quot; and changing the ID could cause problems on postbacks.&lt;/p&gt;&lt;p&gt;kind regards,&lt;/p&gt;&lt;p&gt;Chris&lt;/p&gt;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1374580.aspx</link><pubDate>Fri, 18 Aug 2006 13:53:38 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1374580</guid><dc:creator>hansgh</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1374580.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1374580</wfw:commentRss><description>&lt;p&gt;Thanks, that did the trick.&lt;/p&gt;
&lt;p&gt;I ended up rewriting it a bit so it now looks like this:&lt;/p&gt;
&lt;p&gt;&lt;font color=#008000 size=2&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;&amp;nbsp;&lt;pre class=coloredcode&gt;&lt;span class=cmt&gt;//create the empty row&lt;/span&gt;
GridViewRow emptyRow;
&lt;span class=kwd&gt;if&lt;/span&gt; (&lt;span class=kwd&gt;this&lt;/span&gt;.EmptyDataTemplate != &lt;span class=kwd&gt;null&lt;/span&gt;)
    emptyRow = &lt;span class=kwd&gt;this&lt;/span&gt;.Controls[0].Controls[0] &lt;span class=kwd&gt;as&lt;/span&gt; GridViewRow;
&lt;span class=kwd&gt;else&lt;/span&gt;
{
    emptyRow = &lt;span class=kwd&gt;new&lt;/span&gt; GridViewRow(-1, -1, DataControlRowType.EmptyDataRow, DataControlRowState.Normal);

    TableCell cell = &lt;span class=kwd&gt;new&lt;/span&gt; TableCell();
    cell.ColumnSpan = &lt;span class=kwd&gt;this&lt;/span&gt;.Columns.Count;
    cell.Width = Unit.Percentage(100);
    &lt;span class=kwd&gt;if&lt;/span&gt; (!String.IsNullOrEmpty(EmptyDataText))
        cell.Controls.Add(&lt;span class=kwd&gt;new&lt;/span&gt; LiteralControl(EmptyDataText));
        emptyRow.Cells.Add(cell);
}
table.Rows.Add(emptyRow);
&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1373310.aspx</link><pubDate>Thu, 17 Aug 2006 12:29:32 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1373310</guid><dc:creator>CISCBrain</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1373310.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1373310</wfw:commentRss><description>It's a little hackish, but should work just fine.
Instead of initializing emptyRow like this:
&lt;br /&gt;&lt;br /&gt;
&lt;div&gt;
&lt;font color='black'&gt;GridViewRow&amp;nbsp;emptyRow&lt;/font&gt;&lt;font color='blue'&gt;;&lt;br /&gt;
&lt;/font&gt;&lt;font color='black'&gt;emptyRow&amp;nbsp;&lt;/font&gt;&lt;font color='blue'&gt;=&amp;nbsp;new&amp;nbsp;&lt;/font&gt;&lt;font color='black'&gt;GridViewRow(-&lt;/font&gt;&lt;font color='maroon'&gt;1&lt;/font&gt;&lt;font color='black'&gt;,&amp;nbsp;-&lt;/font&gt;&lt;font color='maroon'&gt;1&lt;/font&gt;&lt;font color='black'&gt;,&amp;nbsp;DataControlRowType.EmptyDataRow,&amp;nbsp;DataControlRowState.Normal)&lt;/font&gt;&lt;font color='blue'&gt;;&lt;br /&gt;
&lt;/font&gt;&lt;font color='black'&gt;TableCell&amp;nbsp;cell&amp;nbsp;&lt;/font&gt;&lt;font color='blue'&gt;=&amp;nbsp;new&amp;nbsp;&lt;/font&gt;&lt;font color='black'&gt;TableCell()&lt;/font&gt;&lt;font color='blue'&gt;;&lt;br /&gt;
&lt;/font&gt;&lt;font color='black'&gt;cell.ColumnSpan&amp;nbsp;&lt;/font&gt;&lt;font color='blue'&gt;=&amp;nbsp;this&lt;/font&gt;&lt;font color='black'&gt;.Columns.Count&lt;/font&gt;&lt;font color='blue'&gt;;&lt;br /&gt;
&lt;/font&gt;&lt;font color='black'&gt;cell.Width&amp;nbsp;&lt;/font&gt;&lt;font color='blue'&gt;=&amp;nbsp;&lt;/font&gt;&lt;font color='black'&gt;Unit.Percentage(&lt;/font&gt;&lt;font color='maroon'&gt;100&lt;/font&gt;&lt;font color='black'&gt;)&lt;/font&gt;&lt;font color='blue'&gt;;&lt;br /&gt;
&lt;br /&gt;
if&amp;nbsp;&lt;/font&gt;&lt;font color='black'&gt;(!String.IsNullOrEmpty(EmptyDataText))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;cell.Controls.Add(&lt;/font&gt;&lt;font color='blue'&gt;new&amp;nbsp;&lt;/font&gt;&lt;font color='black'&gt;LiteralControl(EmptyDataText))&lt;/font&gt;&lt;font color='blue'&gt;;&lt;br /&gt;
&lt;br /&gt;
if&amp;nbsp;&lt;/font&gt;&lt;font color='black'&gt;(&lt;/font&gt;&lt;font color='blue'&gt;this&lt;/font&gt;&lt;font color='black'&gt;.EmptyDataTemplate&amp;nbsp;!&lt;/font&gt;&lt;font color='blue'&gt;=&amp;nbsp;null&lt;/font&gt;&lt;font color='black'&gt;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;EmptyDataTemplate.InstantiateIn(cell)&lt;/font&gt;&lt;font color='blue'&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;/font&gt;&lt;font color='black'&gt;emptyRow.Cells.Add(cell)&lt;/font&gt;&lt;font color='blue'&gt;;&lt;/font&gt;
	&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
Just use the already initialized row:
&lt;br /&gt;&lt;br /&gt;
	&lt;div class='code'&gt;
&lt;font color='black'&gt;emptyRow&amp;nbsp;&lt;/font&gt;&lt;font color='blue'&gt;=&amp;nbsp;this&lt;/font&gt;&lt;font color='black'&gt;.Controls[&lt;/font&gt;&lt;font color='maroon'&gt;0&lt;/font&gt;&lt;font color='black'&gt;].Controls[&lt;/font&gt;&lt;font color='maroon'&gt;0&lt;/font&gt;&lt;font color='black'&gt;]&amp;nbsp;&lt;/font&gt;&lt;font color='blue'&gt;as&amp;nbsp;&lt;/font&gt;&lt;font color='black'&gt;GridViewRow&lt;/font&gt;&lt;font color='blue'&gt;;&lt;/font&gt;
	&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
The row is already initialized because of the call to base.CreateChildControls().</description></item><item><title>Re: GridViewEx</title><link>http://forums.asp.net/thread/1371562.aspx</link><pubDate>Tue, 15 Aug 2006 19:21:10 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1371562</guid><dc:creator>hansgh</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1371562.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=53&amp;PostID=1371562</wfw:commentRss><description>&lt;p&gt;This is a great class indeed, thanks for supplying it!&lt;/p&gt;
&lt;p&gt;However, if I try fetching text from a code-behind function inside the EmptyDataTemplate it doesn't show the text. When debugging it enters the function and returns the text, but it doesn't get displayed. When using the asp:GridView the text shows up nicely (but of course without the header and footer).&lt;/p&gt;
&lt;p&gt;Example:&lt;/p&gt;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;&amp;lt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;EmptyDataTemplate&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;gt;&lt;/font&gt;&lt;/p&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;lt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;asp&lt;/font&gt;&lt;font color=#0000ff size=2&gt;:&lt;/font&gt;&lt;font color=#800000 size=2&gt;Label&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;id&lt;/font&gt;&lt;font color=#0000ff size=2&gt;="lblNoData"&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;runat&lt;/font&gt;&lt;font color=#0000ff size=2&gt;="server"&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;Text&lt;/font&gt;&lt;font color=#0000ff size=2&gt;='&lt;/font&gt;&lt;font size=2&gt;&amp;lt;%# GetNoMessagesText() %&amp;gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;'&lt;/font&gt;&lt;font size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;SkinID&lt;/font&gt;&lt;font color=#0000ff size=2&gt;="Info"&amp;gt;&amp;lt;/&lt;/font&gt;&lt;font color=#800000 size=2&gt;asp&lt;/font&gt;&lt;font color=#0000ff size=2&gt;:&lt;/font&gt;&lt;font color=#800000 size=2&gt;Label&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;gt;&lt;/font&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;lt;/&lt;/font&gt;&lt;font color=#800000 size=2&gt;EmptyDataTemplate&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;gt;&lt;/font&gt;
&lt;p&gt;Do you have any idea why this is and if it can be fixed?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;font size=2&gt;
&lt;p&gt;&lt;/p&gt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&lt;/font&gt;&amp;nbsp;
&lt;p&gt;&lt;font color=#0000ff size=2&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;</description></item></channel></rss>