【发布时间】:2013-12-09 19:32:46
【问题描述】:
GridViewRow row=((GridViewRow )((ImageButton )e.CommandSource ).NamingContainer );
ImageButton imgdelete = (ImageButton)row.FindControl("imgdelete");
string pid = e.CommandArgument.ToString();
if (e.CommandName == "Edit"){
Response.Redirect("PatientRegistration.aspx?pdid=" + pid);
}
if (e.CommandName == "Delete"){
BL_Property.PatientID = pid;
BL_Patient.DeletePatient(BL_Property);
ShowAllPatient();
}
我使用两个图像按钮进行编辑和删除当我点击下一页时我得到了正确的第一页我得到了一个错误
InvalidCastException was unhandled by User code
Error Message :- Unable to cast object of type 'System.Web.UI.WebControls.GridView' to type 'System.Web.UI.WebControls.ImageButton'
【问题讨论】:
-
不要尝试将
GridView转换为ImageButton?