我有以下代码:
<asp:TemplateField HeaderText="Aprovar/Reprovar" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:ImageButton ID="imbAprovar" runat="server"
ImageUrl="~/images/Png0803.png"
OnClientClick="return confirm('Confirma aprovação do chamado?');"
CommandName="APROVAR"
CommandArgument='<%# Eval("nIDChamado") %>'
Height="30" Width="30"
Visible="true" />
<asp:ImageButton ID="imbReprovar" runat="server"
ImageUrl="~/images/Png0798.png"
OnClientClick="return confirm('Confirma não aprovação do chamado?');"
CommandName="REPROVAR"
CommandArgument='<%# Eval("nIDChamado") %>'
Height="30" Width="30"
Visible="true"/>
<ajaxToolkit:Rating ID="AvaliacaoChamado" runat="server"
BehaviorID= '<%# Eval("nIDChamado") %>'
CurrentRating="3"
MaxRating="5"
StarCssClass="ratingStar"
WaitingStarCssClass="savedRatingStar"
FilledStarCssClass="filledRatingStar"
EmptyStarCssClass="emptyRatingStar"
OnChanged="AvaliacaoChamado_Changed"
Visible="false" />
</ItemTemplate>
当我点击imbAprovar或imbReprovar时,我需要做的是隐藏imbAprovar和imbReprovar,同时显示AvaliacaoChamado。我知道我需要更改Visible
属性,但我不知道该怎么做:
protected void GridPesquisar_RowCommand(object sender, GridViewCommandEventArgs e)
{
//Change visiblility
}
这是一个非常广泛且明智的预先存在的代码,我不会在不影响所有系统的情况下自由更改,而且我仍然是ASP.NET和C#的初学者。
答案 0 :(得分:1)
要获得行dp:
GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer;
然后找到按钮并更改其可见性:
Control buttonAprovar = gvr.FindControl("imbAprovar");
if (buttonAprovar != null)
{
buttonAprovar.Visible = false;
}
和第二个按钮相同。