|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Can I Use RequiredFieldValidator inside a repeater ?I use a repeater to display "Name" and "Order". I hope that users can change the "Order" field from the browser. And, if they input invalid value (such as string) in the "Order" field, I hope the validator control can alert them. Can I do this with repeater? Or I should use other webcontrol? Thanks, Simon ---------------------------------------------------------------------------- ------- <asp:repeater id="repeater1" runat="server"> <HeaderTemplate> <table> <TR class="gridHead"> <TD nowrap>Name</TD> <TD nowrap>Order</TD> </TR> </HeaderTemplate> <ItemTemplate> <TR class="gridItem" valign="top"> <TD<%# DataBinder.Eval(Container.DataItem, "Name") %></TD> <TD> <asp:textbox id="txtOrder" runat="server" value="<%# DataBinder.Eval(Container.DataItem, "Order") %>" /> <asp:RequiredFieldValidator ID="valOrder" Runat="server" ControlToValidate="txtOrder" ErrorMessage="Cannot be empty." /> </TD> </TR> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> <asp:repeater> <asp:Button ID="btnSubmit" Runat="server" Text="Submit" /> Repeaters are read only interfaces and don't have a mechanism to switch them
from read only view into edit view (templates). If that is what you need, you should consider a DataList or a DataGrid. RequiredFieldValidators won't check the data to see if it is a string, it will only check to see if there is *some* data. If you need the field to be required AND you need it to be a specific data type, then you'll need 2 validators (a RequiredFieldValidator and a RangeValidator) associated with the one input field. Lastly, yes, you can nest validators inside of DataList and DataGrid controls (as mentioned you wouldn't put them into Repeaters since repeaters aren't for data input). "bhavesh" <bhavesh.***@gmail.com> wrote in message I use a repeater to display "Name" and "Order". I hope that users cannews:1169184718.232385.143450@a75g2000cwd.googlegroups.com... Hello, change the "Order" field from the browser. And, if they input invalid value (such as string) in the "Order" field, I hope the validator control can alert them. Can I do this with repeater? Or I should use other webcontrol? Thanks, Simon ---------------------------------------------------------------------------- ------- <asp:repeater id="repeater1" runat="server"> <HeaderTemplate> <table> <TR class="gridHead"> <TD nowrap>Name</TD> <TD nowrap>Order</TD> </TR> </HeaderTemplate> <ItemTemplate> <TR class="gridItem" valign="top"> <TD<%# DataBinder.Eval(Container.DataItem, "Name") %></TD> <TD> <asp:textbox id="txtOrder" runat="server" value="<%# DataBinder.Eval(Container.DataItem, "Order") %>" /> <asp:RequiredFieldValidator ID="valOrder" Runat="server" ControlToValidate="txtOrder" ErrorMessage="Cannot be empty." /> </TD> </TR> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> <asp:repeater> <asp:Button ID="btnSubmit" Runat="server" Text="Submit" /> THanks a lot dear Scott.
U solved my total confusion. its preety explaination. thanks again a lot. No problem. Good luck with your project.
-Scott Show quoteHide quote "bhavesh" <bhavesh.***@gmail.com> wrote in message news:1169219285.653749.118310@38g2000cwa.googlegroups.com... > THanks a lot dear Scott. > > U solved my total confusion. its preety explaination. > > thanks again a lot. >
#include for a DropDownList?
What's the new thing after ActiveX? AJAX n00b - custom server control in an UpdatePanel causes full postback Collection Property in web custom control CSS substitution for the <center> tag Gridview controls added programmatically does not appear later Setting name=, ID= for TextBox AutoComplete in ASP:TextBox control in ASP.NET 1.1 User Control access fails in debug mode, works in release mode Solution for GridView Pager Style Problem |
|||||||||||||||||||||||