6
Answers

GridView in ASP.NET

Ask a question
Bineesh  VP

Bineesh VP

11y
1.2k
1
Sir, I am working with asp.net Grid.

My issue is that Grid is not displaying on page load in case of  no data in sql Table.

But Grid is showing on page load when i inserted data into table.

can display Grid without data in it?, if can, please send me the code.

Here the code I do:-

public void GridFill()
        {
            DA = new SqlDataAdapter("select * from tbl_Employee", sqlCon);
            dtbl = new DataTable();
            DA.Fill(dtbl);
            cmdbuilder = new SqlCommandBuilder(DA);
            gvEmployee.DataSource = dtbl;
            gvEmployee.DataBind();
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GridFill();
            }
        }

Please help me in this topic.

Answers (6)