R
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") & "::L"
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
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") & "::L"
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