Thursday, 15 May 2014

c# - xVal and Validating multiple rows of data -


I have a table name discount that has the following schema:

PK DiskIDID Int

< / P>

Name varchar (50)

Then I am displaying all the discount related to the customer

Each customer will have 3 discount records.

When I should be unique to process correctly, I create the corresponding text box for the ID and name for editing.

Example:

When I use xVal Trying to experiment because my field names do not match the schema name, 'zodiac' rather than 'amount_1', this field does not validate.

How can I work it out?

I can add all three discounts in a record for a completely different customer, because in some other fields I left to simplify the example. I need 3 discounts in 3 rows for every customer.

Here are some code:

  & lt; Form method = "post" action = "ProcessUpdate" & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; Discount 1 & lt; / Td> & Lt; TD & gt; & Lt;% = Html.TextBox ("zodiac")% & gt; & Lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; Discount 2 & lt; / Td> & Lt; TD & gt; & Lt;% = Html.TextBox ("zodiac 2")% & gt; & Lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; Discount 3 & lt; / Td> & Lt; TD & gt; & Lt;% = Html.TextBox ("zodiac")% & gt; & Lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input type = "submit" value = "submit" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt; & Lt;% = Html.ClientSideValidation & lt; Discount & gt; ()%> Metadata Type (Discount Metadata) Public Partial Discount Discount {Public Class DiscountmataData {[Required (Error Message = " [Required] ")] public string amount {get; Set; }}}  

How to get work done?

I have played something with prefixes and how can this be done:

First you have to give the textbox name for the headline prefix, but the same asset name will be "zodiac" and then attach it to each prix, html. Calling client side validation three times in each field, jquery validators

  & lt; Form method = "post" action = "ProcessUpdate" & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; TD & gt; Discount 1 & lt; / Td> & Lt; TD & gt; & Lt;% = Html.TextBox ("discount1.Amount")% & gt; & Lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; Discount 2 & lt; / Td> & Lt; TD & gt; & Lt;% = Html.TextBox ("discount2.Amount")% & gt; & Lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; Discount 3 & lt; / Td> & Lt; TD & gt; & Lt;% = Html.TextBox ("discount3.Amount")% & gt; & Lt; / Td> & Lt; / Tr & gt; & Lt; TR & gt; & Lt; TD & gt; & Lt; Input type = "submit" value = "submit" /> & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt; & Lt;% = Html.ClientSideValidation & lt; Discount & gt; ("Discount 1")% & gt; & Lt;% = Html.ClientSideValidation & lt; Discount & gt; ("Discount2")% & gt; & Lt;% = Html.ClientSideValidation & lt; Discount & gt; ("Discount3")%>  

Hope this helps


No comments:

Post a Comment