I have the following code:
<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>
What I need to do is hide imbAprovar and imbReprovar while showing AvaliacaoChamado when I click imbAprovar or imbReprovar. I know I need to change the Visible
property, but I don't know how to do right here:
protected void GridPesquisar_RowCommand(object sender, GridViewCommandEventArgs e)
{
//Change visiblility
}
This is very extensive and sensible pre-existing code that I don't have too much freedom to change without impacting all the system, and I'm still a beginner in ASP.NET and C#.
To get the row you can dp:
GridViewRow gvr = (GridViewRow)((Control)e.CommandSource).NamingContainer;
and then to find the buttons and change their visibility:
Control buttonAprovar = gvr.FindControl("imbAprovar");
if (buttonAprovar != null)
{
buttonAprovar.Visible = false;
}
and the same for the second button.