B M Suchitra

B M Suchitra

  • NA
  • 507
  • 418k

Empty Data Template in Gridview not working

Dec 1 2011 11:11 PM
Hi all,

I want to display a the header in the gridview in case there is no data in the sql table... For which i am using the empty data template... But it is not working for me... Please correct me where i am going wrong.. The aspx code is as below:

<asp:GridView ID="GVContact" runat="server" AutoGenerateColumns="False"
  ShowFooter="True" Width="500px" Font-Names="Tahoma" Font-Size="8.25pt"
  ForeColor="Gray">
  <EmptyDataTemplate>
  <asp:TextBox ID="txtContactName" Text='<%#Eval("ContactName") %>' runat="server" CssClass="GridItemStyle"
  Width="90px"></asp:TextBox>
  <asp:TextBox ID="txtemail" runat="server" Text='<%#Eval("ContactEmailID") %>' CssClass="GridItemStyle" Width="90px"></asp:TextBox>
  <asp:TextBox ID="txtmob1" runat="server" Text='<%#Eval("ContactMobile") %>' CssClass="GridItemStyle" Width="90px"></asp:TextBox> 
  </EmptyDataTemplate>
  <Columns>
  <asp:TemplateField HeaderText="Contact Name">
  <ItemTemplate>
  <asp:Label ID="lblcontact" Text='<%#Eval("ContactName") %>' CssClass="TextBoxStyle" runat="server"></asp:Label>
  </ItemTemplate>
  <EditItemTemplate>
  <asp:TextBox ID="txtContactName" Text='<%#Eval("ContactName") %>' runat="server" CssClass="GridItemStyle"
  Width="90px"></asp:TextBox>
  </EditItemTemplate>
  <FooterTemplate>
  <asp:TextBox ID="txtcontact" CssClass="TextBoxStyle" runat="server"></asp:TextBox>
  </FooterTemplate>
  </asp:TemplateField>
 
  <asp:TemplateField HeaderText="Email ID">
  <ItemTemplate>
  <asp:Label ID="lblemail" CssClass="TextBoxStyle" runat="server" Text='<%#Eval("ContactEmailID") %>'></asp:Label>
  </ItemTemplate>
  <EditItemTemplate>
  <asp:TextBox ID="txtemail" runat="server" Text='<%#Eval("ContactEmailID") %>' CssClass="GridItemStyle" Width="90px"></asp:TextBox>

  </EditItemTemplate>
  <FooterTemplate>
  <asp:TextBox ID="txtCemail" CssClass="TextBoxStyle" runat="server"></asp:TextBox>
  </FooterTemplate>
  </asp:TemplateField>
 
  <asp:TemplateField HeaderText="Mobile">
  <ItemTemplate>
  <asp:Label ID="lblmobile" Text='<%#Eval("ContactMobile") %>' CssClass="TextBoxStyle" runat="server"></asp:Label>
  </ItemTemplate>
  <EditItemTemplate>
  <asp:TextBox ID="txtmob1" runat="server" Text='<%#Eval("ContactMobile") %>' CssClass="GridItemStyle" Width="90px"></asp:TextBox>
  </EditItemTemplate>
  <FooterTemplate>
  <asp:TextBox ID="txtCmobile" CssClass="TextBoxStyle" runat="server"></asp:TextBox>
  </FooterTemplate>
  </asp:TemplateField>
 
  <asp:TemplateField HeaderText="Status">
  <ItemTemplate>
  <asp:Label ID="lblstatus" CssClass="TextBoxStyle" runat="server" Text='<%#Eval("ContactStatus") %>'></asp:Label>
  </ItemTemplate>
  <EditItemTemplate>
  <asp:CheckBox ID="chkstatus" Checked="true" runat="server" />
  </EditItemTemplate>
 
  <FooterTemplate>
  <asp:CheckBox ID="chkstatus" Checked="true" runat="server" />
  <asp:Button ID="btnadd" Width="50px" Font-Bold="true" runat="server" Text="add" CssClass="TextBoxStyle" />
  </FooterTemplate>
  </asp:TemplateField>
  <asp:TemplateField>
  <ItemTemplate>
  <asp:LinkButton ID="lnkedit" CommandName="edit" runat="server">edit</asp:LinkButton>
  </ItemTemplate>
 
  </asp:TemplateField>
  </Columns>
  </asp:GridView>


Answers (1)