6
Answers

GridView not displaying data in VS2012

Hi all...

My GridView is not displaying data from datatable.

My code is -
ASPX Page -
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>


<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

  <div id="divPage">
  <asp:UpdatePanel ID="MainUpdatePanel" runat="server" UpdateMode="Always">
  <ContentTemplate>
  <asp:Panel ID="PlnForm" runat="server" CssClass="adminHomeTable">
  <table>
  <tr>
  <td align="center" colspan="6">
  <asp:Label ID="lblHeading" runat="server" Text="User Creation" SkinID="Header" /></td>
  <tr>
  <td colspan="6">
 
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false">
 
  </asp:GridView>

  </td>
  </tr>
  </table>
 
  </asp:Panel>
  </ContentTemplate>
  <Triggers>
 
  </Triggers>
  </asp:UpdatePanel>
  </div>
 

</asp:Content>
----------
ASPX.CS Page -
Page_Load
{
LoadUsers();
}
 private void LoadUsers()
  {
  try
  {
 
 
  BLLAviation2 obj = new BLLAviation2();
  GridView1.DataSource = obj.LoadUsers();
  GridView1.DataBind(); 
 
  }
  catch (Exception err) { err.Message.ToString(); }
  }
--------
My requirement-
Get data from sql server in datatable (say table)
and make this table as a DataSource of GridView1.
I do not want to use any
<Columns>
<asp:BoundField>
</Columns>
Please help.
----
I am getting the data in the datatable, but it is not displayed while viewing the data.
Answers (6)