Home Dashboard Directory Help
Search

Display ASP.NET gridview header/footer when no data present by Alphonse G


Status: 

Closed
 as Won't Fix Help for as Won't Fix


5
0
Sign in
to vote
Type: Suggestion
ID: 228384
Opened: 10/17/2006 5:39:14 AM
Access Restriction: Public
2
Workaround(s)
view

Description

When using a gridview for data editing purposes, there is usually some method of adding new records also.
One very neat, desirable method is to add the necessary controls to the footer of the gridview.
The problem with this is that if there is no data to begin with, the gridview does not display at all.
While I realize it can be done using the empty data row, that requires duplication of the header as well as all the necessary footer controls.
The gridview should have a property to display header/footer when there is no data.
In 1.1 the datagrid always displayed and one could easily hide it if desired.
Details
Sign in to post a comment.
Posted by Microsoft on 11/27/2006 at 11:37 PM

Thanks for your feedback on the .NET Framework! S. Somasegar, the Developer Division VP recently wrote in his blog (http://blogs.msdn.com/somasegar/archive/2006/05/18/601354.aspx) on how the next release of the .NET Framework (codename “Orcas”) requires a high degree of backward compatibility and therefore, how we are being very strict about the number and scope of bugs that are fixed and features that are added in the “Red Bits” during Orcas. Unfortunately, this bug falls into the red bits category, and so we are not able to address it in Orcas due to the potential for it to introduce compatibility issues.

We recognize you submitted this bug because of a specific problem you are experiencing with the product. If you submitted this bug because of a blocking problem you’re experiencing and continue to experience, you may want to contact Microsoft Professional Services http://support.microsoft.com. Alternatively you may find additional information by searching or posting to the ASP.NET forums (http://forums.asp.net). Finally, if you submitted this bug because of a blocking problem you’re experiencing and continue to experience, you may want to also open a support call with Microsoft Professional Services (http://support.microsoft.com/?LN=en-us&scid=gp%3Ben-us%3Bofferprophone&x=8&y=14), which is a better support option when you’re experiencing business impact for your problem and are unable to resolve it in a timely manner on forums or other support channels.

Before starting work on the next full release of the .NET Framework, we will review the Connect data to help us identify and address the top customer reported issues. We’ll broadly review all bugs submitted to date at that time.

Rich Ersek
UI Frameworks Team
Sign in to post a workaround.
Posted by Olivier Jooris on 9/10/2008 at 3:01 AM
''' if the gridview is based on a sqldatasource use this sub:
        '''
        '''Protected Sub GridView3_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView3.DataBound
        '''    Try
        '''Dim gv As GridView = sender
        '''        If gv.Rows.Count smaller or equal 0 Then
        '''select a dummy row
        '''            SqlDataSource4.SelectCommand = "SELECT 0 as [claimid],0 as [claimline],0 as [linetype],0 as [oem],0 as [matnr],0 as [description],0 as [qty],0 as [unitprice] ,0 as [discountperc],0 as [netprice] ,0 as [taxcode],0 as [taxvalue],0 as [dt_cre],0 as [dt_upd]"
        '''            SqlDataSource4.DataBind()
        '''            gv.DataBind()
        '''            gv.Rows(0).Visible = False
        '''        End If
        '''    Catch ex As Exception
        '''        ProcessModuleLoadException(Me, ex)
        '''    End Try
        '''End Sub
        ''' </remarks>
Posted by Alphonse G on 11/28/2006 at 4:35 AM
I have found the following to be an excellent solution.
http://www.codeproject.com/useritems/GridView_with_insert_line.asp