Requiredfield验证程序不适用于下拉列表 [英] Requiredfield validator is not working for dropdownlist

查看:115
本文介绍了Requiredfield验证程序不适用于下拉列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


requiredfieldvalidator不适用于asp.net的gridview控件的页脚模板中的dropdownlist

我的代码如下:

Hi all,


Requiredfieldvalidator is not working for dropdownlist which is present in footer tamplate of gridview control in asp.net

my code is as follows:

<FooterTemplate>
                            <asp:DropDownList ID="ddlcustomer" runat="server" AppendDataBoundItems="true" DataSource='<%#GetCustomer() %>'

                                DataTextField="CustomerName" DataValueField="CusVenID" ValidationGroup ="FtrowValidation">
                                <asp:ListItem Value="-1">-Select-</asp:ListItem>
                            </asp:DropDownList>
                           <asp:RequiredFieldValidator ID="reqfvCustomerName" runat="server" InitialValue="0" ControlToValidate="ddlcustomer"

                                 ValidationGroup="FtrowValidation" ErrorMessage="select Customer"

                                Display="Dynamic" Text ="*"></asp:RequiredFieldValidator>

                        </FooterTemplate>



请告诉我.



please advise me.

推荐答案

先生;
我猜属性InitialValue应该设置为-1,因为默认项"-Select-"的值为-1而不是0.
Sir;
I guess the property InitialValue should set to -1, because the value of the default item ''-Select-'' is -1 not 0.


这篇关于Requiredfield验证程序不适用于下拉列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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