如何验证gridview内的字段并在消息框中显示错误. [英] How to validate field inside a gridview and show errors in message box.

查看:59
本文介绍了如何验证gridview内的字段并在消息框中显示错误.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有gridview,我想验证gridview内的所有字段

我的网格视图为

hi i have gridview ,i want to validate all the field inside gridview

my grid view as

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                                                                          CssClass="GridStyle"
                                                                            Font-Names="Tahoma" Font-Size="11px"
                                                                            HeaderStyle-CssClass="HeaderStyle" HorizontalAlign="Left"

                                                                             Width="100%">
                                                                            <%--<RowStyle BorderColor="Silver" BorderStyle="Solid" BorderWidth="1px" ForeColor="Blue"
                                                    Wrap="True" />--%>
                                                                            <Columns>

                                                                                     <asp:CommandField
               ShowEditButton="True" CausesValidation="true" ValidationGroup="ValGrpEdit"></asp:CommandField>


                                                                                <asp:TemplateField ShowHeader="False">
                                                                                    <ItemTemplate>
                                                                                        <asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False"
                                                                                            CommandName="Delete" Text="Delete"></asp:LinkButton>
                                                                                    </ItemTemplate>
                                                                                </asp:TemplateField>

                                                                                <asp:TemplateField HeaderText="Name" SortExpression="Name">
                                                                                    <EditItemTemplate>
                                                                                        <asp:TextBox ID="Name1" runat="server" CssClass="text" Text=''<%# Bind("Name") %>''
                                                                                            ValidationGroup="ValGrpEdit"></asp:TextBox>
                                                                                        <asp:RequiredFieldValidator ID="RequiredName" runat="server" ControlToValidate="Name1"
                                                                                            ErrorMessage="Please enter a valid Name."  EnableClientScript="true" ValidationGroup="ValGrpEdit" Width="16px">*</asp:RequiredFieldValidator>
                                                                                    </EditItemTemplate>
                                                                                    <ItemTemplate>
                                                                                        <asp:Label ID="Name2" runat="server" Text=''<%# Bind("Name") %>''></asp:Label>
                                                                                    </ItemTemplate>
                                                                                    <ItemStyle ForeColor="Black" Width="15%" />
                                                                                    <ControlStyle />
                                                                                </asp:TemplateField>




                                                                                <asp:TemplateField HeaderText="Path" SortExpression="Path">
                                                                                    <EditItemTemplate>
                                                                                        <asp:TextBox ID="Path1"  ValidationGroup="ValGrpEdit" runat="server" CssClass="text" Height="76px" Text=''<%# Bind("Path") %>''
                                                                                            TextMode="MultiLine"></asp:TextBox>
                                                                                        <asp:CustomValidator ID="txtApplicationPathV" ValidationGroup="ValGrpEdit" runat="server"
                                                                                            ErrorMessage="Please fill in a path either in URL / Path or URL / Path" ClientValidationFunction="ValidateEdit"
                                                                                            ControlToValidate="Path1" ValidateEmptyText="true">*</asp:CustomValidator>
                                                                                    </EditItemTemplate>
                                                                                    <ItemTemplate>
                                                                                        <asp:Label ID="Path2" runat="server" CssClass="DisplayDesc" Text=''<%# Bind("Path") %>''
                                                                                            Visible="false"></asp:Label>

                                                                                    </ItemTemplate>
                                                                                    <ItemStyle ForeColor="Black" />
                                                                                    <ControlStyle />
                                                                                </asp:TemplateField>




                                                                            </Columns>

                                                                        </asp:GridView>



我尝试了所有可能,但无法验证字段,也无法显示消息框.请帮助..



i tryied every possibilities,but am unable to validate the fields,also not able to show message box.please help..

推荐答案

尝试使用vb代码比脚本更容易应用
try using vb codes man, vb codes is more easier to apply than script


这篇关于如何验证gridview内的字段并在消息框中显示错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆