Add row to grid view

前端 未结 5 2341
庸人自扰
庸人自扰 2021-02-14 08:28

Is it possible to programmatically add a row to a GridView in C# ASP?

If yes, how ?

I want to add static data directly from the code, not from an array nor an da

5条回答
  •  别那么骄傲
    2021-02-14 08:50

    DataTable dt = new DataTable();
    DataRow dr = dt.NewRow();
    dr["Column1"] = string.Empty;
    dt.Rows.Add(dr);
    

    You can then bind your GridView to the DataTable...

    gv.DataSource = dt;
    gv.DataBind();
    

提交回复
热议问题