单击Gridview时如何禁用Gridview中的链接按钮 [英] How to disable a link button in Gridview when clicked on it
本文介绍了单击Gridview时如何禁用Gridview中的链接按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在GridView批准和拒绝中有两个链接按钮我想要单击它时批准linkButton。我尝试了以下代码,但它无法正常工作。
I have two Link buttons in GridView Approve and Reject I want Approve linkButton to be disabled when i click on it. I tried the following code but its not working.
protected void gvManagerTimeSheet_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ApproveRow")
{
GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
LinkButton lnkbtn = (LinkButton)row.FindControl("lbApprove");
lnkbtn.Enabled = false;
int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex;
int TimeSheetId = Convert.ToInt32(e.CommandArgument);
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand("spApproveTimeSheet ", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@TimeSheetId", TimeSheetId);
con.Open();
cmd.ExecuteNonQuery();
GetManagerTimeSheets();
}
}
推荐答案
这样做
Hi,
Do This
LinkButton lnkBt = (LinkButton)e.CommandSource;
lnkBt.Enabled = false;
这篇关于单击Gridview时如何禁用Gridview中的链接按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文