本文介绍了删除Gridview中的选定行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试删除gridview中的选定行,用户可以选择要删除的行,并且他一次只能删除一行。怎么办呢。
在.CS页面下我写了以下代码。
protected void gdvData_RowDeleting( object sender,GridViewDeleteEventArgs e)
{
InBoundDataBO obj = new InBoundDataBO();
int SUPPLIER_NUMBER = Convert.ToInt32(gdvData.Rows [e.RowIndex] .Cells [ 4 ]文本);
string SOURCE_ENTITY = gdvData.Rows [e.RowIndex] .Cells [ 2 ]。的ToString();
string PLANT_CODE = gdvData.Rows [e.RowIndex] .Cells [ 3 ]。的ToString();
string SUPPLIER_GROUP_NUMBER = gdvData.Rows [e.RowIndex] .Cells [ 5 ]。的ToString();
obj.DeleteSupplierDetails(SUPPLIER_NUMBER,SOURCE_ENTITY,PLANT_CODE,SUPPLIER_GROUP_NUMBER);
}
在Data Acess Layer下我写了以下方法。
public static void DeleteSupplierDetails( String R1, String R2, String R3, String R4, out 字符串消息)
{
message = String .Empty;
数据库db = Helper.CreateDatabase();
DbCommand cmd = db.GetStoredProcCommand( PDSS_STAGING_DEV.Delete_SupplierDetails);
cmd.CommandType = CommandType.StoredProcedure;
db.AddInParameter(cmd, P_SOURCE_ENTITY, DbType。 String ,R1);
db.AddInParameter(cmd, P_PLANT_CODE,DbType。 String ,R2);
db.AddInParameter(cmd, P_SUPPLIER_NUMBER,DbType。 String ,R3);
db.AddInParameter(cmd, P_SUPPLIER_GROUP_NUMBER,DbType。 String ,R4);
db.AddOutParameter(cmd, P_RETURN_MSG,DbType。 String , 10 );
db.ExecuteNonQuery(cmd);
message = cmd.Parameters [ P_RETURN_MSG]。Value.ToString()。Trim ();
}
解决方案
I am trying to delete a selected row in the gridview, the User has a option of selecting the row to be deleted and he can delete only one row at a time. How can this be done.
Under the .CS page i have written the following code.
protected void gdvData_RowDeleting(object sender, GridViewDeleteEventArgs e) { InBoundDataBO obj = new InBoundDataBO(); int SUPPLIER_NUMBER = Convert.ToInt32(gdvData.Rows[e.RowIndex].Cells[4].Text); string SOURCE_ENTITY = gdvData.Rows[e.RowIndex].Cells[2].Text.ToString(); string PLANT_CODE = gdvData.Rows[e.RowIndex].Cells[3].Text.ToString(); string SUPPLIER_GROUP_NUMBER = gdvData.Rows[e.RowIndex].Cells[5].Text.ToString(); obj.DeleteSupplierDetails(SUPPLIER_NUMBER, SOURCE_ENTITY, PLANT_CODE, SUPPLIER_GROUP_NUMBER); }
Under the Data Acess Layer i have written the following method.
public static void DeleteSupplierDetails(String R1, String R2, String R3, String R4,out String message) { message = String.Empty; Database db = Helper.CreateDatabase(); DbCommand cmd = db.GetStoredProcCommand("PDSS_STAGING_DEV.Delete_SupplierDetails"); cmd.CommandType = CommandType.StoredProcedure; db.AddInParameter(cmd, "P_SOURCE_ENTITY", DbType.String, R1); db.AddInParameter(cmd, "P_PLANT_CODE", DbType.String, R2); db.AddInParameter(cmd, "P_SUPPLIER_NUMBER", DbType.String, R3); db.AddInParameter(cmd, "P_SUPPLIER_GROUP_NUMBER", DbType.String, R4); db.AddOutParameter(cmd,"P_RETURN_MSG", DbType.String,10); db.ExecuteNonQuery(cmd); message = cmd.Parameters["P_RETURN_MSG"].Value.ToString().Trim(); }
解决方案
这篇关于删除Gridview中的选定行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!