我正在尝试从editItemTemplate中的textBox获取文本,似乎没有任何工作。我试图在我的RowUpdating中使用FindControl但仍然没有运气。我在c#工作。关于如何让它发挥作用的任何好的步骤?
答案 0 :(得分:0)
你需要根据gridview的行索引找到这样的控件。
protected void gvMemberClassificationDetail_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
HiddenField hdMemberCode = this.gvMemberClassificationDetail.Rows[e.RowIndex].FindControl("hidID") as System.Web.UI.WebControls.HiddenField;
DropDownList status = this.gvMemberClassificationDetail.Rows[e.RowIndex].FindControl("ddlClassificationStatus") as System.Web.UI.WebControls.DropDownList;
TextBox Comments = this.gvMemberClassificationDetail.Rows[e.RowIndex].FindControl("txtRemarks") as System.Web.UI.WebControls.TextBox;
ObjectDataSource4.UpdateParameters["memberCode"].DefaultValue = hdMemberCode.Value;
ObjectDataSource4.UpdateParameters["status"].DefaultValue = status.SelectedValue;
ObjectDataSource4.UpdateParameters["comments"].DefaultValue = Comments.Text;
}