What is wrong with this c# method?
private void getMydatatable()
{
DataTable dt = new DataTable();
DataColumn dc;
dc = new DataColumn("Name");
dt.Columns.Add(dc);
dc = new DataColumn("Age");
dt.Columns.Add(dc);
dt.Rows.Add("ARUN", "23");
dt.Rows.Add("BALA", "23");
GridView1.AutoGenerateColumns = false;
GridView1.DataSource = dt;
GridView1.DataBind();
Page.Controls.Add(GridView1);
}
This method gets called on page load but my gridview is invisible why?
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DlUser" runat="server">
</asp:DropDownList>
<asp:CheckBoxList ID="ChkUser" runat="server">
</asp:CheckBoxList>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
</div>
</form>