protected void OnRowCommand(object server, GridViewCommandEventArgs e)
{
int rowindex = Convert.ToInt32(e.CommandArgument);
int fileid = Convert.ToInt32(((Label)gvAssignReviewer.Rows[rowindex].FindControl("lblFileId")).Text);
System.Windows.Forms.MessageBox.Show(gvAssignRequest.Rows[rowindex].Cells[0].Text);
String urevid = (((TextBox)gvAssignReviewer.Rows[rowindex].FindControl("txtReviewerId")).Text);
ur.UpdateReviewer(fileid, urevid);
Bind();
}
它正在给我FileID,因为它出现在DataGrid上,但在UrevID中,我没有在文本框中获得更新的值,因此我得到空引用异常。请帮帮我。
答案 0 :(得分:0)
protected void ASPxGridView1_CustomColumnDisplayText(object sender,
ASPxGridViewColumnDisplayTextEventArgs e)
{
if (e.Column.FieldName == "Column1")
{
int a= Convert.ToInt32(e.Value).ToString();
}
if (e.Column.FieldName == "Column2")
{
string b= e.Value.ToString();
}
答案 1 :(得分:0)
您需要检查Label
中是否找到了TextBox
或GridviewRow
。我会这样做:
protected void OnRowCommand(object server, GridViewCommandEventArgs e)
{
// Don't use Windows Message Box
int rowindex = Convert.ToInt32(e.CommandArgument);
var lblFileId = gvAssignReviewer.Rows[rowindex].FindControl("lblFileId") as Label;
var txtReviewerId = gvAssignReviewer.Rows[rowindex].FindControl("txtReviewerId") as TextBox;
if(lblFileId != null && txtReviewerId != null)
{
int fileId;
int urevId;
if(int.TryParse(lblFileId.Text, out fileId) && int.TryParse(txtReviewerId.Text, out urevId) )
{
ur.UpdateReviewer(fileId, urevId);
}
}
Bind();
}