1
I have a Radionbutton with Repeatdirection which is generated on my Datagrid, yes and no button.
<asp:TemplateColumn HeaderText ="Reevio" ItemStyle-Wrap="false" ItemStyle-Font-Size="8" HeaderStyle-Font-Size="9">
<ItemTemplate>
<asp:RadioButtonList ID="RBLIndicaReenvio" runat="server" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="RBLIndicaReevio_SelectedIndexChanged">
<asp:ListItem Value="S" Text="Sim" ></asp:ListItem>
<asp:ListItem Value="N" Text="Não" Selected="true"></asp:ListItem>
</asp:RadioButtonList>
</ItemTemplate>
</asp:TemplateColumn>
And here, I have a txb and a button also generated in the grid.
<asp:TemplateColumn HeaderText ="Digite Seu E-Mail" Visible ="false" ItemStyle-Wrap="false" ItemStyle-Font-Size="8" HeaderStyle-Font-Size="9">
<ItemTemplate >
<asp:TextBox ID="TXBEmail" Visible ="false" runat="server" Width="200" CssClass="txbEmail" ></asp:TextBox>
<asp:Button ID="BTNEnviar" Visible ="false" runat="server" Text="Enviar" Width="60" OnClick="BTNEnviar_Click"></asp:Button>
</ItemTemplate>
</asp:TemplateColumn>
This is code Behind
protected void RBLIndicaReevio_SelectedIndexChanged(object sender, EventArgs e)
{
RadioButtonList objectClick = (RadioButtonList)sender;
int columnReenvio = Util.getColIndexByHeader(dgRegistros, "Digite Seu E-Mail");
foreach (DataGridItem dr in dgRegistros.Items)
{
RadioButtonList radio;
TextBox email;
Button enviar;
radio = ((RadioButtonList)dr.Cells[columnReenvio].FindControl("RBLIndicaReenvio"));
email = ((TextBox)dr.Cells[columnReenvio].FindControl("TXBEmail"));
enviar = ((Button)dr.Cells[columnReenvio].FindControl("BTNEnviar"));
if (radio == objectClick)
{
if (radio.SelectedValue == "S")
{
dgRegistros.Columns[Util.getColIndexByHeader(dgRegistros, "Digite Seu E-Mail")].Visible = true;
dr.Cells[columnReenvio].Visible = true;
enviar.Visible = true;
email.Visible = true;
}
else
{
//dgRegistros.Columns[Util.getColIndexByHeader(dgRegistros, "Digite Seu E-Mail")].Visible = false;
dr.Cells[columnReenvio].Visible = true;
enviar.Visible = false;
email.Visible = false;
}
}
}
how could I validate if all the radios are as No ?
show man! thanks for the help. I got another way.
– Diego Garcia
I counted the number of lines and compared with the number of selected buttons. 


int rowCount = dgRegistros.Items.Count;
 int countRadio = 0;

 RadioButtonList radioaux;

 foreach (DataGridItem dr in dgRegistros.Items)
 {
 radioaux = ((RadioButtonList)dr.Cells[columnReenvio].FindControl("RBLIndicaReenvio"));
 if (radioaux.SelectedValue == "N")
 {
 countRadio = countRadio + 1;
 }

 }
– Diego Garcia
The logic is pretty much the same, what changes is that you used a counter instead of a boolean. Don’t forget to mark the answer that solved your problem so you can close the topic
– Victor Laio
Yes man, I did it after I read your answer, thanks :D
– Diego Garcia