1
public void BuildBranches()
{
    DataTable dtBranches = new DataTable();
    divBranches.Controls.Clear();
    objsupplyPL.username = Session["username"].ToString();
    dtBranches = objsupplyBAL.GetBPFEnteredBranches(objsupplyPL);
    if (dtBranches.Rows.Count > 0)
    {
        for (int i = 0; i < dtBranches.Rows.Count; i++)
        {

            DataTable dtIndentDetails = new DataTable();
            string branches = dtBranches.Rows[i]["branch"].ToString();
            objsupplyPL.branch = branches;
            dtIndentDetails = objsupplyBAL.GetStock(objsupplyPL);

            Table tbldynamic = new Table();
            TableRow tr = new TableRow();
            TableCell tc = new TableCell();



            string st = dtBranches.Rows[i]["branch"].ToString();



            GridView gv = new GridView();
            gv.ID = "gv" + dtBranches.Rows[i]["branch"].ToString();
            gv.Width = 500;

            BoundField bfpurchaseid = new BoundField();
            bfpurchaseid.HeaderText = "Productid";
            bfpurchaseid.DataField = "productid";
            gv.Columns.Add(bfpurchaseid);

            BoundField bfProductId = new BoundField();
            bfProductId.HeaderText = "Product Name";
            bfProductId.DataField = "productname";
            gv.Columns.Add(bfProductId);              

            BoundField bfIssue = new BoundField();
            bfIssue.HeaderText = "Issue";
            gv.Columns.Add(bfIssue);

            BoundField bfgrno = new BoundField();
            bfgrno.HeaderText = "Transfer";
            gv.Columns.Add(bfgrno);

            gv.DataKeyNames = new string[]
            {
                "keys","branch"
            };


            gv.RowDataBound += new GridViewRowEventHandler(gv_RowDataBound);
            gv.RowCommand += new GridViewCommandEventHandler(gv_RowCommand);

            gv.AutoGenerateColumns = false;
            gv.EmptyDataText = "No Records Found";
            gv.DataSource = dtIndentDetails;
            gv.DataBind();
            divBranches.Controls.Add(tbldynamic);
            divBranches.Controls.Add(gv);

            LiteralControl @break1 = default(LiteralControl);
            @break1 = new LiteralControl("<br />");
            divBranches.Controls.Add(@break1);

        }
    }
}

动态网格视图工作正常。我想为用户提供编辑选项以更新网格

BoundField 是否可以更新网格?或者我必须创建模板字段?请帮助我解决有关动态网格的方法。

4

0 回答 0