Deekshaa Singh Chauhan

Deekshaa Singh Chauhan

  • 1.7k
  • 178
  • 11.4k

why gridview is not visible when we run

May 27 2018 5:41 AM
I'm adding a GridView & then showing data in it from a SQL Server database. The problem is that the GridView is not displaying in the browser with or without data.
 
  1. <asp:GridView ID="grdLocation" runat="server" AutoGenerateColumns="False"   
  2.         onrowdatabound="grdLocation_RowDataBound"   
  3.         onrowdeleted="grdLocation_RowDeleted" Width="100%" CssClass="grid-view"   
  4.         EnableModelValidation="True" ViewStateMode="Enabled">  
  5.        <Columns>     
  6.            <asp:TemplateField HeaderText="Location Name">  
  7.                <ItemTemplate>  
  8.                    <asp:Label ID="lblShowLocationName" runat="server" Text='<%# Eval("Name") %>'></asp:Label>  
  9.                </ItemTemplate>  
  10.                <EditItemTemplate>  
  11.                    <asp:TextBox ID="txtEditLocationName" runat="server" Text='<%# Eval("Name") %>'></asp:TextBox>  
  12.                    <asp:RequiredFieldValidator ID="rfvLocationName" runat="server" ControlToValidate="txtEditLocationName" SetFocusOnError="true" ErrorMessage="*" ValidationGroup="LocationUpdate"></asp:RequiredFieldValidator>  
  13.                    <%--<asp:RegularExpressionValidator ID="rexvLocationNameEdit" runat="server" ControlToValidate="txtEditLocationName" SetFocusOnError="true" ValidationGroup="Location" ValidationExpression="^[a-zA-Z ]*$" ErrorMessage="Only Alphabets Allowed" Display="Dynamic"></asp:RegularExpressionValidator>--%>  
  14.                </EditItemTemplate>  
  15.                <HeaderStyle HorizontalAlign="Left" VerticalAlign="Middle" />  
  16.                <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />  
  17.            </asp:TemplateField>  
  18.            <asp:TemplateField HeaderText="Location Code">  
  19.                <ItemTemplate>  
  20.                    <asp:Label ID="lblShowLocationCode" runat="server" Text='<%# Eval("Code") %>'></asp:Label>  
  21.                </ItemTemplate>  
  22.                <EditItemTemplate>  
  23.                    <asp:TextBox ID="txtEditLocationCode" runat="server" Text='<%# Eval("Code") %>'   
  24.                        ></asp:TextBox>  
  25.                      
  26.                </EditItemTemplate>  
  27.                <ItemStyle HorizontalAlign="Left" VerticalAlign="Middle" />  
  28.            </asp:TemplateField>  
  29.            <asp:TemplateField>  
  30.                <ItemTemplate>  
  31.                    <asp:ImageButton ID="imgBtnshow" runat="server" ToolTip="View"   
  32.                        CommandArgument='<%# Eval("LocationId") %>' ImageUrl="~/Images/file_edit.png"  
  33.                        onclick="imgBtnshow_Click" />  
  34.                </ItemTemplate>  
  35.                <EditItemTemplate>  
  36.                    <asp:ImageButton ID="imgBtnEdit" runat="server" CommandArgument='<%# Eval("LocationId") %>' ImageUrl="~/Images/buttonsave.png" OnClick="imgBtnEdit_Click" ValidationGroup="LocationUpdate" ToolTip="Update" />  
  37.                    <asp:ImageButton ID="imgBtnCancel" runat="server" ToolTip="Cancel"  
  38.                    ImageUrl="~/Images/1350368827_save_delete.png" onclick="imgBtnCancel_Click"/>  
  39.                </EditItemTemplate>  
  40.                <ItemStyle Width="50px" />  
  41.            </asp:TemplateField>  
  42.            <asp:TemplateField>  
  43.                <ItemTemplate>  
  44.                    <asp:ImageButton ID="imgBtnDelete" runat="server" CommandArgument='<%# Eval("LocationId") %>' ImageUrl="~/Images/delete-256.png" OnClick="imgBtnDelete_Click" OnClientClick="Confirm()" ToolTip="Delete"/>  
  45.                </ItemTemplate>  
  46.                <ItemStyle Width="50px" />  
  47.            </asp:TemplateField>  
  48.              
  49.        </Columns>  
  50.     </asp:GridView>  
 

Answers (3)