473,221 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,221 software developers and data experts.

dynamic validation does not work

parshupooja
159 100+
hey all,

I have DataTable binded to Gridview . This Datatable contains Data from Database. Before binding it to Gridview I am adding extra line with few controls dynamically in it such as text box below. When page loads I see extra Text box on the bottom of gridview but Validation is not working. Any Idea?

I am calling this Function on each page load.

Expand|Select|Wrap|Line Numbers
  1. Private Sub AddControls()
  2. Dim con As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
  3.         Dim cmd1 As SqlCommand = New SqlCommand("sp_get", con)
  4.         cmd1.CommandType = CommandType.StoredProcedure
  5.         Dim da1 As SqlDataAdapter = New SqlDataAdapter(cmd1)
  6.         Dim dt1 As DataTable = New DataTable
  7.         da1.Fill(dt1)
  8.         Dim dr1 As DataRow = dt1.NewRow
  9.         dt1.Rows.InsertAt(dr1, 0)
  10.  
  11.        Dim txtqty As New TextBox
  12.         txtqty.ID = "txtqtyextra"
  13.         txtqty.Width = 20
  14.  
  15.         Dim validation As New RequiredFieldValidator
  16.         validation.ID = "reqvaltxtqty"
  17.         validation.ControlToValidate = txtqty.ID
  18.         validation.ErrorMessage = "*"
  19.  
  20.         Dim custvalidation As New CompareValidator
  21.         custvalidation.ID = "custvalidationtxtqty"
  22.         custvalidation.ControlToValidate = txtqty.ID
  23.         custvalidation.ErrorMessage = "Value should be greater than 0"
  24.         custvalidation.Type = ValidationDataType.Integer
  25.         custvalidation.Operator = ValidationCompareOperator.GreaterThan
  26.         custvalidation.ValueToCompare = 0
  27. GridView1.Rows(GridView1.Rows.Count - 1).Cells(2).Controls.Add(txtqty)
  28.  End Sub
  29.  
Jun 30 '09 #1
0 1095

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: mr_burns | last post by:
hi, is it possible to change the contents of a combo box when the contents of another are changed. for example, if i had a combo box called garments containing shirts, trousers and hats, when...
1
by: Toby Miller | last post by:
I have this form validation that I'm trying to build, but it's not working properly. A dynamic function to the onsubmit event for a form. the result of that function (true/false) should then be...
1
by: Mike George | last post by:
I am having a problem with dynamic validation controls. I have some code that uses an XSLT to transform an XMLDocument into HTML which creates ASP.NET validation controls dynamically (v 1.1). ...
1
by: Luis Ferrao | last post by:
Hi, To understand the problem, a small description of the situation should be provided: I have a Field Control that is made of a one row table with three columns. The table width is 100%, the...
1
by: Nathan Sokalski | last post by:
When testing a form of mine which uses RequiredFieldValidators that have the Display property set to "Dynamic" the ErrorMessage property is automatically removed when an entry is completely typed...
3
by: rgparkins | last post by:
Hi I am currently having problems with Validators in a user control. I am creating a wizard sign-up process which have the allocated step (hyperlinks" at the top of the page. A user can also...
5
by: matt | last post by:
hello, i am on an interesting project. in this project, i have to create dynamic data-entry forms for offline-users to fill out, save locally, and eventually postback to our app (when back...
0
by: Steve Funk | last post by:
All, I have searched all around and have not yet found the answer to this nor a solution. Hopfully it will be easy to overcome. Here is what I am trying to do: I'm trying to build a wizard...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.