|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Formfields in Repeaters - validation and save into DBI have a repeater, which generated form fields: <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /> <asp:Repeater ID="RepeaterRevenues1" runat="server" DataSourceID="Revenues1DataSource"> <ItemTemplate> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="CustomValidator" OnServerValidate="CustomValidator_ServerValidate" ControlToValidate="TextBoxQuota"></asp:CustomValidator> <asp:TextBox ID="TextBoxQuota" runat="server" Text='<%# Bind("Quota") %>'></asp:TextBox> </ItemTemplate> </asp:Repeater> Wenn I press Button1 then validation is called (in CustomValidator_ServerValidate). It checks if data are valid and I set isValid = false or true. Then method is called: Button1_Click and here I have problems ... In the method Button1_Click ... how can I check if validation is false or true ? Method CustomValidator_ServerValidate is called a few times - 1 time for every loop-cycle. When isValid is false at least one time then whole form won't be valid. And how can I read the data from form fields ? (I'd like to save them in the DB). RepeaterRevenues1.FindControl doesn't give me right results. Thank you for help in advance. with best regards, Rafal Rafal schrieb:
Show quoteHide quote > I have a repeater, which generated form fields: Hi> > <asp:Button ID="Button1" runat="server" Text="Button" > OnClick="Button1_Click" /> > > <asp:Repeater ID="RepeaterRevenues1" runat="server" > DataSourceID="Revenues1DataSource"> > <ItemTemplate> > <asp:CustomValidator ID="CustomValidator1" runat="server" > ErrorMessage="CustomValidator" > OnServerValidate="CustomValidator_ServerValidate" > ControlToValidate="TextBoxQuota"></asp:CustomValidator> > > <asp:TextBox ID="TextBoxQuota" runat="server" Text='<%# Bind("Quota") > %>'></asp:TextBox> > </ItemTemplate> > </asp:Repeater> > > Wenn I press Button1 then validation is called (in > CustomValidator_ServerValidate). > It checks if data are valid and I set isValid = false or true. > > Then method is called: > Button1_Click > > and here I have problems ... > In the method Button1_Click ... how can I check if validation is false or > true ? > Method CustomValidator_ServerValidate is called a few times - 1 time for > every loop-cycle. > > When isValid is false at least one time then whole form won't be valid. > > And how can I read the data from form fields ? (I'd like to save them in the > DB). > RepeaterRevenues1.FindControl doesn't give me right results. if you iterate every rendered row, you can get the controls by FindControl ex. VB.Net (not tested) Dim cItem As RepeaterItem = Nothing For Each cItem In RepeaterRevenues1 Dim cValidator AS CustomValidator = CType(cItem.FindControl("CustomValidator1"), CustomValidator) .... Next rb Hi,
it helped, now my problem is solved :-) Thank you very much. with best regards, Rafal
WebParts without SharePoint
How to format wizard? Problem accessing controls ReportViewer Causing Major Problems file upload and download Render web custom control Dropdownlist selected value Any way to set attributes for server controls by referencing properties/methods/variables? MOSS 2007 WebParts in ASP.Net 2.0 Application Strange Behavior W/MasterPage |
|||||||||||||||||||||||