来自btnclick的方法未调用 [英] from btnclick the method is not called

查看:139
本文介绍了来自btnclick的方法未调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经关注过的大家好

我在行绑定方法的网格中动态添加按钮
代码如下
受保护的void gvwPlanDetail_RowDataBound(object sender,GridViewRowEventArgs e)
{
如果(e.Row.RowType == DataControlRowType.DataRow)
{
字符串状态= e.Row.Cells [4] .Text;
如果(status.ToLower()=="ACCEPTED" .ToLower())
{
ImageButton btnCancel = new ImageButton();
btnCancel.ImageUrl =".. \\ images \\ Cancel_New.gif";
btnCancel.ToolTip =取消方案";
btnCancel.Click + = new ImageClickEventHandler(btnCancel_Click);
e.Row.Cells [4] .Controls.Add(btnCancel);
}
}
}


我在这里添加btnCancel_点击此方法
此方法中的代码是
受保护的无效btnCancel_Click(对象发送者,ImageClickEventArgs e)
{
GridViewRow gridViewRow =(GridViewRow)(发送方为控件).Parent.Parent;
int索引= gridViewRow.RowIndex;
objClients.ClientCode = gvwPlanDetail.Rows [index] .Cells [0] .Text;
objClients.SchemeName = gvwPlanDetail.Rows [index] .Cells [1] .Text;
objClientBase.CancelPlan(objClients);
BindGvwPlanDetail();

}


但是当我单击取消"按钮时,它无法导航到该方法
请告诉我
在这一点上我错了.

谢谢你

hello guys i have following

I am Adding Dynamically Button in grid on rowbound method
code is as follow
protected void gvwPlanDetail_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string status = e.Row.Cells[4].Text;
if (status.ToLower() == "ACCEPTED".ToLower())
{
ImageButton btnCancel = new ImageButton();
btnCancel.ImageUrl = "..\\images\\Cancel_New.gif";
btnCancel.ToolTip = "Cancel Scheme";
btnCancel.Click +=new ImageClickEventHandler(btnCancel_Click);
e.Row.Cells[4].Controls.Add(btnCancel);
}
}
}


here i am addinng btnCancel_Click this method
code in this method are
protected void btnCancel_Click(object sender, ImageClickEventArgs e)
{
GridViewRow gridViewRow = (GridViewRow)(sender as Control).Parent.Parent;
int index = gridViewRow.RowIndex;
objClients.ClientCode = gvwPlanDetail.Rows[index].Cells[0].Text;
objClients.SchemeName = gvwPlanDetail.Rows[index].Cells[1].Text;
objClientBase.CancelPlan(objClients);
BindGvwPlanDetail();

}


but when i click on cancel button it can not navigate to the that method
please tell me
at which point i m wrong.

thank u

推荐答案

protected void gvwPlanDetail_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string status = e.Row.Cells[4].Text;
if (status.ToLower() == "ACCEPTED".ToLower())
{
ImageButton btnCancel = new ImageButton();
btncancel.id="img1"
btnCancel.ImageUrl = "..\\images\\Cancel_New.gif";
btnCancel.ToolTip = "Cancel Scheme";
btnCancel.Click +=new ImageClickEventHandler(btnCancel_Click);
e.Row.Cells[4].Controls.Add(img1);
}
}
}
 

here i am addinng btnCancel_Click this method
code in this method are 
protected void btnCancel_Click(object sender, ImageClickEventArgs e)
{
GridViewRow gridViewRow = (GridViewRow)(sender as Control).Parent.Parent;
int index = gridViewRow.RowIndex;
objClients.ClientCode = gvwPlanDetail.Rows[index].Cells[0].Text;
objClients.SchemeName = gvwPlanDetail.Rows[index].Cells[1].Text;
objClientBase.CancelPlan(objClients);
BindGvwPlanDetail();
 
}


"System.Web.UI.ControlCollection.Add(System.Web.UI.Control)"的最佳重载方法匹配具有一些无效的参数

它会
显示此错误


请提到您要更改代码的地方
The best overloaded method match for ''System.Web.UI.ControlCollection.Add(System.Web.UI.Control)'' has some invalid arguments

it will
show this error


plz mention where u are changing the code


控件应该在每次页面加载时都加载.
因此请从页面加载中删除ispost.
上面的解决方案.
the control should be loaded each time on page load.
therefore remove the ispost from page load.
solution of above.


这篇关于来自btnclick的方法未调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆