【问题标题】:ASP .net Add a row to Grid view as a first indexASP .net 在网格视图中添加一行作为第一个索引
【发布时间】:2017-05-29 22:40:34
【问题描述】:

我想在 Gridview 上添加一行,这意味着要在 gridview 上添加一行作为第一条记录。 示例代码如下 ` protected void getfinaldetails_Click(对象发送者,EventArgs e) {

        DataSet ResultDS = new DataSet();
        //  string timespan = TimeSelection.SelectedValue;

        string fromdate = txtfromDate.Text;
        string todate = txtToDate.Text;

        string freepermit = "paid";
        Label1.Text = "Paid Permit Amount Details";
        Label2.Visible = false;
        ResultDS = DLCON.AdminAmount(fromdate, todate, freepermit);



        GridAmountView.DataSource = ResultDS;
        GridAmountView.DataBind();


    }

`

【问题讨论】:

    标签: asp.net gridview indexing row newrelic


    【解决方案1】:

    您可以创建一个新的 DataTable 并将其绑定到 gridview,但它不使用 DLCON。

    System.Data.DataTable dt = new System.Data.DataTable();
    dt.Columns.Add("fromdate", typeof(string));
    dt.Columns.Add("todate", typeof(string));
    dt.Columns.Add("freepermit", typeof(string));
    dt.Rows.Add(new object[] { fromdate, todate, freepermit });
    

    如果你得到一个 DataSet(里面有表),你想使用类似myDataSet.Tables[0] 的东西来获取第一个表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-08-31
      • 2023-03-21
      • 2011-03-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-25
      • 1970-01-01
      相关资源
      最近更新 更多