ASP.NET and C# - Gridview line obligation

Asked

Viewed 135 times

0

Just as there is in forms of ASP.Net sites the Requiredfieldvalidator, which requires the filling of a field, there is some way to have a mandatory gridview with at least one line?

For example, I have on my website (ASP.Net with C#) a part of resume registration. As a mandatory field, it has the training of the user, which he must fill with one of the items of the Dropdownlist.

Then you have the option to add the training courses. Each course added goes to a Gridview. Then I would need to have this gridview as a requirement for him to register the curriculum. If you do not have this gridview present (with at least one data line), it does not register the resume.

Follow the code of Gridview:

<asp:GridView ID="gwFormacao" runat="server" AutoGenerateColumns="False" HeaderStyle-BackColor="#E74310" HeaderStyle-ForeColor="White">
                                    <Columns>
                                        <asp:BoundField DataField="curso" HeaderText="Curso" HtmlEncode="False" />
                                        <asp:BoundField DataField="instituicao" HeaderText="Instituição" HtmlEncode="False" />
                                        <asp:BoundField DataField="anoConclusao" HeaderText="Ano/Previsão de conclusão" HtmlEncode="False" />
                                        <asp:TemplateField HeaderText="Op&#231;&#245;es">
                                        <ItemTemplate>
                                            <asp:ImageButton ID="imgBtnExcluirFormacao" runat="server" ImageUrl="~/imagens/excluir16.png" ToolTip="Excluir situação" CommandArgument='<%# DataBinder.Eval(Container,"RowIndex") %>' oncommand="imgBtnExcluirFormacao_Command" />
                                            <ajaxtoolkit:ConfirmButtonExtender ID="cbeExcluirSituacao" runat="server" TargetControlID="imgBtnExcluirFormacao" DisplayModalPopupID="pmeConfirmBox"></ajaxtoolkit:ConfirmButtonExtender>
                                            <ajaxtoolkit:ModalPopupExtender ID="pmeConfirmBox" runat="server" TargetControlID="imgBtnExcluirFormacao" PopupControlID="pnlPopUpConfirm" OkControlID="lkbOk" CancelControlID="lkbCancelar"></ajaxtoolkit:ModalPopupExtender>
                                            <asp:Panel ID="pnlPopUpConfirm" runat="server" DefaultButton="lkbOk" CssClass="panel">
                                                <table width="100%">
                                                    <tr>
                                                        <td colspan="2" align="left"><asp:Label ID="lblTitulo" runat="server" Text="Questão"></asp:Label></td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 60px" valign="middle" align="left"><asp:Image ID="imgPopUp" runat="server" ImageUrl="~/imagens/confirmacao32.png" /></td>
                                                        <td valign="middle" align="left"><asp:Label ID="lblMensagem" runat="server" Text="Confirma exclusão da formação"></asp:Label></td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="2" align="right">
                                                            <asp:LinkButton ID="lkbOk" runat="server" Text="Ok"></asp:LinkButton>
                                                            &nbsp;&nbsp;<asp:LinkButton ID="lkbCancelar" runat="server" Text="Cancelar"></asp:LinkButton>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </asp:Panel>
                                        </ItemTemplate>
                                        <ItemStyle HorizontalAlign="Center" Width="35px" />
                                        </asp:TemplateField>
                                    </Columns>
                                    </asp:GridView>
  • 1

    You can check the number of grid lines in the datagrid Itemdatabound. Or check the content of the datagrid datasource.

  • @Danieljunior Do you have any idea how I put this in code?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.