无法将类型 'Obout.Grid.GridTemplate' 的对象转换为类型 'System.Web.UI.WebControls.GridViewRow'。没有解决
Unable to cast object of type 'Obout.Grid.GridTemplate' to type 'System.Web.UI.WebControls.GridViewRow'. not resolving
我想 disable gridview
在 gridview 中单击按钮时的行。为此,我编写了以下代码。
protected void btnPayGenInvoice_Click(object sender, EventArgs e)
{
if (strMode == "M")
{
Button btn = (Button)sender;
GridViewRow row = (GridViewRow)btn.Parent.Parent;
row.Enabled = false;
}
}
但我收到错误
Unable to cast object of type 'Obout.Grid.GridTemplate' to type 'System.Web.UI.WebControls.GridViewRow'.
请告诉我这里有什么问题
更新
在第 GridViewRow row = (GridViewRow)btn.Parent.Parent;
行出现错误
更新 2
按钮点击事件的代码。
protected void GetRowDataPay(object sender, CommandEventArgs e)
{
int rowIndex = int.Parse(e.CommandArgument.ToString());
Hashtable dataItemPay = GridPayInfo.Rows[rowIndex].ToHashtable() as Hashtable;
if (ObjPriCon.State != ConnectionState.Open)
{
ObjPriCon.Open();
OracleCommand cmdMkeyPay = new OracleCommand("select XXCUS.XXACL_LAND_PURC_INV_VIEW_MKEY.nextval from dual", ObjPriCon);
string MkeyPay = Convert.ToString(cmdMkeyPay.ExecuteOracleScalar());
OracleCommand cmdORGID = new OracleCommand("select XXCUS.XXACL_LAND_PURC_INV_VIEW_MKEY.nextval from dual", ObjPriCon);
string ORG_IDKEY = CF.ExecuteScaler2("select ORGANIZATION_ID,ORGANIZATION_NAME from apps.xxacl_company_mst where ORGANIZATION_NAME = '" + txtCompName.Value + "'");
string strExpQuery = "insert into XXCUS.XXACL_LAND_PURC_INVOICE_VIEW (MKEY,REF_PURCHASE_ID,REF_SR_NO, " +
"REF_PURHCASE_TYPE,ORG_ID,PROJECT_ID,TALUKA_ID,VILLAGE_ID,SURVEY_AREA_7_12,DOC_NO,INVOICE_ID,INVOICE_NUM,VENDOR_ID, " +
"VENDOR_NAME,INVOICE_AMT,BATCH_ID,BATCH_NAME,EXP_ID,EXP_TYPE,REMARKS,CREATED_BY, " +
"CREATION_DATE,LAST_UPDATE_DATE,LAST_UPDATED_BY, EXP_ORG_ID, EXP_ORG_NAME) values (" + MkeyPay + "," + StrMkey + "," +
"" + dataItemPay["SR_NO"] + ", '" + dataItemPay["ATTRIBUTE1"] + "'," + ORG_IDKEY + "," + ddlProject.SelectedValue + "," +
"" + ddlTaluka.SelectedValue + "," + ddlVillage.SelectedValue + ", '" + txt712.Text + "', '" + txtdocno.Value + "'," + "NULL" + "," + "NULL" + "," +
"" + dataItemPay["ORACLE_VENDOR_ID"] + ", '" + dataItemPay["ORACLE_VEND_NAME"] + "', " + dataItemPay["PAID_AMT"] + "," + dataItemPay["BATCH_ID"] + "," +
"'" + dataItemPay["BATCH_NAME"] + "', " + dataItemPay["EXP_ID"] + ", '" + dataItemPay["EXP_TYPE"] + "', '" + dataItemPay["REMARKS"] + "', " +
"" + Request.QueryString["userid"].ToString() + ", sysdate, sysdate, " +
"'" + Request.QueryString["userid"].ToString() + "', " + "NULL" + "," + "NULL" + ")";
OracleCommand cmdQuery = new OracleCommand(strExpQuery, ObjPriCon);
cmdQuery.ExecuteNonQuery();
ObjPriCon.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "Success", "alert('Payment Invoice inserted into table successfully');", true);
}
}
您应该使用 rowIndex 值来获取 gridviewrow,然后像这样禁用它
if (GridPayInfo.Rows[rowIndex] != null)
{
GridPayInfo.Rows[rowIndex].Enabled = false;
}
我想 disable gridview
在 gridview 中单击按钮时的行。为此,我编写了以下代码。
protected void btnPayGenInvoice_Click(object sender, EventArgs e)
{
if (strMode == "M")
{
Button btn = (Button)sender;
GridViewRow row = (GridViewRow)btn.Parent.Parent;
row.Enabled = false;
}
}
但我收到错误
Unable to cast object of type 'Obout.Grid.GridTemplate' to type 'System.Web.UI.WebControls.GridViewRow'.
请告诉我这里有什么问题
更新
在第 GridViewRow row = (GridViewRow)btn.Parent.Parent;
更新 2
按钮点击事件的代码。
protected void GetRowDataPay(object sender, CommandEventArgs e)
{
int rowIndex = int.Parse(e.CommandArgument.ToString());
Hashtable dataItemPay = GridPayInfo.Rows[rowIndex].ToHashtable() as Hashtable;
if (ObjPriCon.State != ConnectionState.Open)
{
ObjPriCon.Open();
OracleCommand cmdMkeyPay = new OracleCommand("select XXCUS.XXACL_LAND_PURC_INV_VIEW_MKEY.nextval from dual", ObjPriCon);
string MkeyPay = Convert.ToString(cmdMkeyPay.ExecuteOracleScalar());
OracleCommand cmdORGID = new OracleCommand("select XXCUS.XXACL_LAND_PURC_INV_VIEW_MKEY.nextval from dual", ObjPriCon);
string ORG_IDKEY = CF.ExecuteScaler2("select ORGANIZATION_ID,ORGANIZATION_NAME from apps.xxacl_company_mst where ORGANIZATION_NAME = '" + txtCompName.Value + "'");
string strExpQuery = "insert into XXCUS.XXACL_LAND_PURC_INVOICE_VIEW (MKEY,REF_PURCHASE_ID,REF_SR_NO, " +
"REF_PURHCASE_TYPE,ORG_ID,PROJECT_ID,TALUKA_ID,VILLAGE_ID,SURVEY_AREA_7_12,DOC_NO,INVOICE_ID,INVOICE_NUM,VENDOR_ID, " +
"VENDOR_NAME,INVOICE_AMT,BATCH_ID,BATCH_NAME,EXP_ID,EXP_TYPE,REMARKS,CREATED_BY, " +
"CREATION_DATE,LAST_UPDATE_DATE,LAST_UPDATED_BY, EXP_ORG_ID, EXP_ORG_NAME) values (" + MkeyPay + "," + StrMkey + "," +
"" + dataItemPay["SR_NO"] + ", '" + dataItemPay["ATTRIBUTE1"] + "'," + ORG_IDKEY + "," + ddlProject.SelectedValue + "," +
"" + ddlTaluka.SelectedValue + "," + ddlVillage.SelectedValue + ", '" + txt712.Text + "', '" + txtdocno.Value + "'," + "NULL" + "," + "NULL" + "," +
"" + dataItemPay["ORACLE_VENDOR_ID"] + ", '" + dataItemPay["ORACLE_VEND_NAME"] + "', " + dataItemPay["PAID_AMT"] + "," + dataItemPay["BATCH_ID"] + "," +
"'" + dataItemPay["BATCH_NAME"] + "', " + dataItemPay["EXP_ID"] + ", '" + dataItemPay["EXP_TYPE"] + "', '" + dataItemPay["REMARKS"] + "', " +
"" + Request.QueryString["userid"].ToString() + ", sysdate, sysdate, " +
"'" + Request.QueryString["userid"].ToString() + "', " + "NULL" + "," + "NULL" + ")";
OracleCommand cmdQuery = new OracleCommand(strExpQuery, ObjPriCon);
cmdQuery.ExecuteNonQuery();
ObjPriCon.Close();
ScriptManager.RegisterStartupScript(this, this.GetType(), "Success", "alert('Payment Invoice inserted into table successfully');", true);
}
}
您应该使用 rowIndex 值来获取 gridviewrow,然后像这样禁用它
if (GridPayInfo.Rows[rowIndex] != null)
{
GridPayInfo.Rows[rowIndex].Enabled = false;
}