2015-09-04 41 views
0

我想获得特定的单元格值,所以我可以将它传递给我的方法,当我按下按钮,但我总是空两个(我知道这不是空值)。如何从RadGrid中的单元格获取值C#asp.net

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); 


       } 


      } 
     } 

回答

1

最后我使用此代码

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); 


        } 
       } 
      } 
做到了
相关问题