Как включить текстовое поле, вложенное в gridview, в событии rowediting ?
Как включить текстовое поле, вложенное в Gridview, в событии RowEditing ?
protected void MyGrid_RowEditing(object sender, GridViewEditEventArgs e) { string CampID; //int id = Convert.ToInt32(MyGrid.DataKeys[e.].ToString()); CampID = (Session["CampaignID"].ToString()); mf.UpdateStatus(CampID, 'X'); MyGrid.EditIndex = e.NewEditIndex; //string lblOfferType = MyGrid.Rows[e.NewEditIndex].Cells[4].Text; GridViewRow currentRow = this.MyGrid.Rows[e.NewEditIndex]; string lblOfferType = (currentRow.FindControl("lblOffer_Type") as Label).Text; //string freeQty = (currentRow.FindControl("txtFree_Qty") as TextBox).Text; //string discPercent = (currentRow.FindControl("txtDisc_Percent") as TextBox).Text; //TextBox discValue = (currentRow.FindControl("txtDisc_Value") as TextBox); //string offerPrice = (currentRow.FindControl("txtOffer_Price") as TextBox).Text; //string freeArticle = (currentRow.FindControl("txtFree_Article") as TextBox).Text; if (lblOfferType == "VALUE DISCOUNT") { GridViewRow row = (GridViewRow)((Control)sender).NamingContainer; GridViewRow currentRow1 = this.MyGrid.Rows[e.NewEditIndex]; ((TextBox)MyGrid.Rows[e.NewEditIndex].FindControl("txtDisc_Value")).Enabled = false; //discValue.Enabled = true; //(currentRow.FindControl("txtDisc_Value") as TextBox).Enabled = true; //((TextBox)currentRow.FindControl("txtDisc_Value")).Enabled = true; } }
Ошибка: ссылка на объект не установлена на экземпляр.
Пожалуйста, предоставьте решение.
Что я уже пробовал:
protected void MyGrid_RowEditing(object sender, GridViewEditEventArgs e) { string CampID; //int id = Convert.ToInt32(MyGrid.DataKeys[e.].ToString()); CampID = (Session["CampaignID"].ToString()); mf.UpdateStatus(CampID, 'X'); MyGrid.EditIndex = e.NewEditIndex; //string lblOfferType = MyGrid.Rows[e.NewEditIndex].Cells[4].Text; GridViewRow currentRow = this.MyGrid.Rows[e.NewEditIndex]; string lblOfferType = (currentRow.FindControl("lblOffer_Type") as Label).Text; //string freeQty = (currentRow.FindControl("txtFree_Qty") as TextBox).Text; //string discPercent = (currentRow.FindControl("txtDisc_Percent") as TextBox).Text; //TextBox discValue = (currentRow.FindControl("txtDisc_Value") as TextBox); //string offerPrice = (currentRow.FindControl("txtOffer_Price") as TextBox).Text; //string freeArticle = (currentRow.FindControl("txtFree_Article") as TextBox).Text; if (lblOfferType == "VALUE DISCOUNT") { GridViewRow row = (GridViewRow)((Control)sender).NamingContainer; GridViewRow currentRow1 = this.MyGrid.Rows[e.NewEditIndex]; ((TextBox)MyGrid.Rows[e.NewEditIndex].FindControl("txtDisc_Value")).Enabled = false; //discValue.Enabled = true; //(currentRow.FindControl("txtDisc_Value") as TextBox).Enabled = true; //((TextBox)currentRow.FindControl("txtDisc_Value")).Enabled = true; } }