0

第一行的下拉列表为空。我需要在下拉列表中添加列。这是我的代码:

  private void grdbind()
   {
    DataTable db = new DataTable();
    db = (DataTable)Session["csvdata"];
    DataRow newrow = db.NewRow();
    db.Rows.InsertAt(newrow, 0);
    dgData.DataSource = db;
    dgData.DataBind();


}

此代码用于在第一个位置添加下拉列表:

 protected void dgData_RowDataBound(object sender, GridViewRowEventArgs e)
{

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        DropDownList ddl;
        if (e.Row.RowIndex == 0)
        {
            for (Int32 i = 0; i < e.Row.Cells.Count; i++)
            {
                ddl = new DropDownList();
                ddl.ID = "ddlCol" + i.ToString();

                e.Row.Cells[i].Controls.Add(ddl);
            }
        }


    }

现在我想要的是绑定这个下拉列表。??

4

0 回答 0