如何在Radgrid中从单元格中获取值

本文关键字:单元格 获取 Radgrid | 更新日期: 2023-09-27 18:11:04

我试图获得特定的单元格值,所以当我按下按钮时,我可以在我的方法中传递它,但我总是在两者上得到null(我知道这不是null)。

p。s:没有行被选中,因为我做了一个循环来获取所有行。变量"p"得到正确的行数,我有在网格上。

  protected void PostRadButton_Click(object sender, EventArgs e)
        {
            int p;
            if (DocStatTxtBox.Text == "2")
            {
                foreach (GridDataItem item in RadGrid1.Items)
                {
                    p = item.RowIndex;
                    string itemcodeparam = item["ItemCode"].Text;//error null (4th cell)
                    int quantityparam = Convert.ToInt16(item.Cells[5].Text);//error null
                    Boolean x = Methods.UpdateStock(WhTxtBoxRadDropDownList.SelectedValue,itemcodeparam,-quantityparam);

                }

            }
        }

如何在Radgrid中从单元格中获取值

最后我用下面的代码完成了

protected void PostRadButton_Click(object sender, EventArgs e)
            {
                int p;
                if (DocStatTxtBox.Text == "2")
                {
                    foreach (GridDataItem item in RadGrid1.Items)
                    {
                            p = item.RowIndex;
                            Label itemparam = (Label)item["ItemCode"].FindControl("ItemCodeLabel");
                            Label qparam = (Label)item["Quantity"].FindControl("QuantityLabel");

                            string itemcodeparam = itemparam.Text;
                            int quantityparam = Convert.ToInt16(qparam.Text);
                            Boolean x = Methods.UpdateStock(WhTxtBoxRadDropDownList.SelectedValue, itemcodeparam, -quantityparam);

                    }
                }
            }