【发布时间】:2021-06-17 03:32:59
【问题描述】:
我已经在我的数据集中输入了这个条件
- 当 message 的值等于
"1"时,无法继续在此网页上工作... - 当 message 的值等于
"0"时,可以继续,但无法编辑gridview数据...
下面是我的代码
if (message == 1)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('test msg 1');window.location='Default.aspx';", true);
return null;
}
else if (message == 0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "alert('test msg 2');", true);
btrila.Visible = false;
btnreset.Visible = true;
return dsProducts;
}
else
{
return dsProducts;
}
当消息的值等于"0" 时,我需要隐藏或禁用edit 下方的按钮gridview 数据
<ItemTemplate>
<asp:ImageButton ID="btnedit" runat="server"
CommandName="Edit"
ImageUrl="/aspnet/img/edit_icon.gif"
ToolTip="Edit" />
</ItemTemplate>
我在RowDataBound 中尝试过这个解决方案但没有成功,因为"btnedit" 总是被隐藏...
任何帮助将不胜感激...谢谢。
protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.DataItem != null)
{
if (btnreset.Visible == true)
{
gvProducts.Columns[2].Visible = false;
}
else
{
gvProducts.Columns[2].Visible = true;
}
}
}
}
【问题讨论】: