Click here to Skip to main content
15,891,942 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have the GridView and I bind the data with this.
Also, I have mentioned Emptydatatemplate in the gridview, if there is No Record.
But, the tag Emptydatatemplate not displaying even if there is no Record.
What is the problem over here.
See my code:
------------
ASPX Page
---------
ASP.NET
<asp:GridView ID="grdData" runat="server" align="center" AutoGenerateColumns="False" class="tabulardata" 
                                 HorizontalAlign="Center" Width="50%" OnRowCancelingEdit="grdData_RowCancelingEdit" 
                                 OnRowDataBound="grdData_RowDataBound" OnRowEditing="grdData_RowEditing" OnRowUpdating="grdData_RowUpdating" 
                                 OnRowCommand="grdData_RowCommand" ShowFooter="True" AllowPaging="true" OnRowUpdated="grdData_RowUpdated">
                                 <columns>
                                     <asp:TemplateField HeaderText="Sl.No" ItemStyle-HorizontalAlign="Center" 
                                         ItemStyle-Width="4%">
                                         <itemtemplate>
                                             <asp:Label ID="Sno" runat="server">
                                         </itemtemplate>
                                         <itemstyle horizontalalign="Center" />
                                     
                                     <asp:BoundField HeaderText="Emp Number" Visible="true" DataField="EmpNo"
                                         ItemStyle-HorizontalAlign="center" ReadOnly="true" SortExpression="EmpNo">
                                         <itemstyle horizontalalign="Center" width="20%" />
                                     
                                    <asp:BoundField HeaderText="EmpName" Visible="true" DataField="EmpName"
                                         ItemStyle-HorizontalAlign="center" ReadOnly="true" SortExpression="EmpName">
                                         <itemstyle horizontalalign="Center" width="20%" />
                                     
                                 
                                 </columns>
                                 <alternatingrowstyle backcolor="#EAEAFF" />
                                  <emptydatarowstyle backcolor="LightBlue" forecolor="Red" />
                                   <emptydatatemplate>
                                      <asp:image id="NoDataImage" imageurl="~/Images/Edit.png" alternatetext="No Image" runat="server"/>
                                            No Data Found.  
                                   </emptydatatemplate> 
ASPX.VB Code
------------
VB
 Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  If Not IsPostBack Then
          FillGridValues()
 End If
End Sub
Public Sub FillGrid_BIDDataValues()
        Conn.Open()
        Qry = ""
        Qry = "select * from EmpTab"
        SQLDA = New SqlDataAdapter(Qry, Conn)
        dttable = New DataTable
        SQLDA.Fill(dttable)
        If dttable.Rows.Count > 0 Then
            grdData.DataSource = dttable
            grdData.DataBind()
        End If
        Conn.Close()
    End Sub
Posted
Updated 24-Aug-11 0:31am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900