I am trying to create a Gridview that allows me to add to a database. I think I have the Gridview formatted correctly and I do not want to use the <emptydatarowstyle>. I have been playing around with different solutions to displaying a header and footer in a gridview with no data in it all day. I beleive I am REALLY close but cant seem to bring it together and have it show so please a point in the right direction would be much appreciated. I will attach my gridview control as well as my code.
<asp:GridView ID="PurchaseOrderOfficeEquipmentGridView"
backcolor="#F1F1F1"
DataSourceID="SQLPurchaseOrdersDataSource"
DataKeyNames="PROPERTY_ID"
ShowFooter="True"
ShowHeader="true"
runat="server"
>
<Columns>
<asp:TemplateField HeaderText="Office Equipment">
<ItemTemplate>
<asp:Label ID="lblOfficeEQ" Text='<%# eval("PURCHASE_ORDER_OFFICE_EQUIPMENT") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPO_Office_EQ" Text='<%# eval("PURCHASE_ORDER_OFFICE_EQUIPMENT") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPO_Office_EQ" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price">
<ItemTemplate>
<asp:Label ID="lblOfficePR" Text='<%# eval("PURCHASE_ORDER_OFFICE_PRICE") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPO_Office_PR" Text='<%# eval("PURCHASE_ORDER_OFFICE_PRICE") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPO_Office_PR" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:Label ID="lblOfficeQU" Text='<%# eval("PURCHASE_ORDER_OFFICE_QUANTITY") %>' runat="server"></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPO_Office_QU" Text='<%# eval("PURCHASE_ORDER_OFFICE_QUANTITY") %>' runat="server"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPO_Office_QU" runat="server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" />
<asp:TemplateField HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="linkDeleteCust" CommandName="Delete" runat="server">Delete</asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="linkAddRow" CommandName="AddRow" runat="server">+Add</asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Imports System.Data
Partial Class GridView
Inherits System.Web.UI.Page
Public Sub CheckEmptyGrid(ByVal dv As DataView)
Try
Dim ds As DataSet = New DataSet()
Dim dt As DataTable = dv.Table
ds.Tables.Add(dt)
If ds.Tables(0).Rows.Count = 0 Then
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow())
PurchaseOrderOfficeEquipmentGridView.DataSource = ds
PurchaseOrderOfficeEquipmentGridView.DataBind()
Dim columnCount = PurchaseOrderOfficeEquipmentGridView.Rows(0).Cells.Count
PurchaseOrderOfficeEquipmentGridView.Rows(0).Cells.Clear()
PurchaseOrderOfficeEquipmentGridView.Rows(0).Cells.Add(New TableCell())
PurchaseOrderOfficeEquipmentGridView.Rows(0).Cells(0).ColumnSpan = columnCount
PurchaseOrderOfficeEquipmentGridView.Rows(0).Cells(0).Text = "Add Records"
End If
Catch ex As Exception
End Try
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim dssa As New DataSourceSelectArguments
CheckEmptyGrid(SQLPurchaseOrdersDataSource.Select(dssa))
End Sub
End Class