473,320 Members | 1,841 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,320 software developers and data experts.

Adding a Compare Validator dynamically from code

RSH

I have a situation where I am generating webcontrols dynamically from
codebehind (1.1)

Everything is working properly except that I am also attempting to add a
Compare Validator which doesn't appear to be working, I get the error: "
Unable to find control id '67:::EX' referenced by the 'ControlToValidate'
property of ''.
which makes sense, but it begs the question can this be done??

cmdReader = New OleDbCommand(strSQL, cnReportDownloads)

dtrReader = cmdReader.ExecuteReader()

PlaceHolder1.Controls.Add(New LiteralControl("<table>"))

While dtrReader.Read

PlaceHolder1.Controls.Add(New LiteralControl("<tr><td>" &
dtrReader("FileName") & "</td><td>"))

Dim tb1 As New TextBox

tb1.ID = dtrReader("FileID") & ":::DL"

tb1.Width = Unit.Pixel(30)

tb1.Text = dtrReader("DownloadsLeft")

PlaceHolder1.Controls.Add(tb1)

PlaceHolder1.Controls.Add(New LiteralControl("</td><td>"))

Dim tb2 As New TextBox

tb2.ID = dtrReader("FileID") & ":::EX"

strSplit = Split(dtrReader("Expires"), " ")

tb2.Text = strSplit(0)

tb2.Width = Unit.Pixel(120)

PlaceHolder1.Controls.Add(tb2)

Dim vc As New CompareValidator

vc.ControlToValidate = tb2.ID

vc.Operator = ValidationCompareOperator.DataTypeCheck

vc.Type = ValidationDataType.Date

vc.ErrorMessage = "Please enter a valid date in the format: mm/dd/yyyy"

PlaceHolder1.Controls.Add(vc)

PlaceHolder1.Controls.Add(New LiteralControl("</td></tr>"))

End While

Dim bu As New Button

bu.ID = "Button2"

bu.Text = "Submit Changes"

PlaceHolder1.Controls.Add(New LiteralControl("<tr><td colspan='3'
align='center'><br><br>"))

PlaceHolder1.Controls.Add(bu)

PlaceHolder1.Controls.Add(New LiteralControl("</td></tr>"))

PlaceHolder1.Controls.Add(New LiteralControl("</table>"))

Thanks!

Ron
Jun 5 '06 #1
0 1103

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
3
by: thomson | last post by:
Hi, I have 5 aspx pages, In one page i have a Compare Validator Control, The four aspx pages are loading fast with similar controls, no code behind, But the page having Compare Validator Control...
0
by: sonic | last post by:
I am trying to dynamically load a validator and must be missing something elementary here. I extended TextBox control to add some functionality to it. One new feature it contains is IsRequired...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.