R
Ryan Ternier
Hello,
I have a repeater control that does the following on the ItemDataBound
event. It works perfectly, except that when it prints out, the names of the
controls
aren't what I'd expect.
lstYes.ID = "lstY" & drvTemp("UserID") 'Assuming ID is the part we want form
the DB
I use that to set the ID of the listBox, but when it comes to the screen it
has a name of
rptSecurity:ctrl00:lstYes14
Or something similar to that.
Is there a way to make that control just have lstYes14?
If Not e.Item.DataItem Is Nothing Then
Try
Dim intTypeID = CInt(Request.QueryString.Get("TypeID"))
Dim objItemType As ItemType
objItemType = New ItemType(CInt(intTypeID))
'Get the current item that's being bound from the DB
Dim drvTemp As DataRowView = CType(e.Item.DataItem, DataRowView)
'Get handles on the server side controls so we can edit them through
code. l337 pwn4g3
Dim lstYes As ListBox = CType(e.Item.FindControl("listYes"),
ListBox)
Dim lstNo As ListBox = CType(e.Item.FindControl("listNo"), ListBox)
Dim lblButtons As Label = CType(e.Item.FindControl("LabelButtons"),
Label)
Dim lblName As Label = CType(e.Item.FindControl("LabelName"), Label)
lstYes.ID = "lstY" & drvTemp("UserID") 'Assuming ID is the part we
want form the DB
lstYes.SelectionMode = ListSelectionMode.Multiple
lstNo.ID = "lstN" & drvTemp("UserID") 'Assuming ID is the part we
want form the DB
lstNo.SelectionMode = ListSelectionMode.Multiple
lblName.Text = drvTemp("FullName")
'Response.Write(drvTemp("FullName") & "<BR>")
For i As Integer = 0 To objItemType.Layout.Count() - 1
lstYes.Items.Add(objItemType.Layout.Item(i).Field.Caption())
lstYes.Items(i).Value = objItemType.Layout.Item(i).Field.FieldID
Next
'Put raw HTML into the Label control to build the 4 button table to move
items between the list boxes.
'To switch the items between listboxes
'onclick="SwitchList(document.getElementById('lstNotifyAvailable'),
document.getElementById('lstNotifySelected'));AdNotify(document.getElementBy
Id('lstNotifyAvailable'));
With lblButtons
Text = "<table>"
.Text &= "<tr><td>"
.Text &= "<input type=""button"" class=""BoxType42""
value=""Allow All"" name=""btn" & drvTemp("UserID") & "AA""
onclick=""SwitchList(document.getElementById('" & lstYes.ID.ToString & "'),
document.getElementById ('" & lstNo.ID.ToString &
"'));AddNotify(document.getElementById('" & lstYes.ID.ToString() & "'));"">"
.Text &= "</td></tr>"
.Text &= "<tr><td>"
.Text &= "<input type=""button"" class=""BoxType42""
value=""Allow"" name=""btn" & drvTemp("UserID") & "A""
onclick=""Allow(document.Security." & lstYes.ID.ToString() &
",document.Security." & lstNo.ID.ToString() & ");"">"
.Text &= "</td></tr>"
.Text &= "<tr><td>"
.Text &= "<input type=""button"" class=""BoxType42""
value=""Disallow All"" name=""btn" & drvTemp("UserID") & "DA""
onclick=""DisAll(document.Security." & lstYes.ID.ToString() &
",document.Security." &
lstNo.ID.ToString() & ");"">"
.Text &= "</td></tr>"
.Text &= "<tr><td>"
.Text &= "<input type=""button"" class=""BoxType42""
value=""Disallow"" name=""btn" & drvTemp("UserID") & "D""
onclick=""Disallow(document.Security." & lstYes.ID.ToString() &
",document.Security." &
lstNo.ID.ToString() & ");"">"
.Text &= "</td></tr>"
.Text &= "</table>"
End With
Catch ex As Exception
Debug.WriteLine(ex.ToString)
Response.Write("<BR>_______________________<BR>" & ex.ToString &
"<BR>")
Response.Flush()
End Try
End If
I have a repeater control that does the following on the ItemDataBound
event. It works perfectly, except that when it prints out, the names of the
controls
aren't what I'd expect.
lstYes.ID = "lstY" & drvTemp("UserID") 'Assuming ID is the part we want form
the DB
I use that to set the ID of the listBox, but when it comes to the screen it
has a name of
rptSecurity:ctrl00:lstYes14
Or something similar to that.
Is there a way to make that control just have lstYes14?
If Not e.Item.DataItem Is Nothing Then
Try
Dim intTypeID = CInt(Request.QueryString.Get("TypeID"))
Dim objItemType As ItemType
objItemType = New ItemType(CInt(intTypeID))
'Get the current item that's being bound from the DB
Dim drvTemp As DataRowView = CType(e.Item.DataItem, DataRowView)
'Get handles on the server side controls so we can edit them through
code. l337 pwn4g3
Dim lstYes As ListBox = CType(e.Item.FindControl("listYes"),
ListBox)
Dim lstNo As ListBox = CType(e.Item.FindControl("listNo"), ListBox)
Dim lblButtons As Label = CType(e.Item.FindControl("LabelButtons"),
Label)
Dim lblName As Label = CType(e.Item.FindControl("LabelName"), Label)
lstYes.ID = "lstY" & drvTemp("UserID") 'Assuming ID is the part we
want form the DB
lstYes.SelectionMode = ListSelectionMode.Multiple
lstNo.ID = "lstN" & drvTemp("UserID") 'Assuming ID is the part we
want form the DB
lstNo.SelectionMode = ListSelectionMode.Multiple
lblName.Text = drvTemp("FullName")
'Response.Write(drvTemp("FullName") & "<BR>")
For i As Integer = 0 To objItemType.Layout.Count() - 1
lstYes.Items.Add(objItemType.Layout.Item(i).Field.Caption())
lstYes.Items(i).Value = objItemType.Layout.Item(i).Field.FieldID
Next
'Put raw HTML into the Label control to build the 4 button table to move
items between the list boxes.
'To switch the items between listboxes
'onclick="SwitchList(document.getElementById('lstNotifyAvailable'),
document.getElementById('lstNotifySelected'));AdNotify(document.getElementBy
Id('lstNotifyAvailable'));
With lblButtons
Text = "<table>"
.Text &= "<tr><td>"
.Text &= "<input type=""button"" class=""BoxType42""
value=""Allow All"" name=""btn" & drvTemp("UserID") & "AA""
onclick=""SwitchList(document.getElementById('" & lstYes.ID.ToString & "'),
document.getElementById ('" & lstNo.ID.ToString &
"'));AddNotify(document.getElementById('" & lstYes.ID.ToString() & "'));"">"
.Text &= "</td></tr>"
.Text &= "<tr><td>"
.Text &= "<input type=""button"" class=""BoxType42""
value=""Allow"" name=""btn" & drvTemp("UserID") & "A""
onclick=""Allow(document.Security." & lstYes.ID.ToString() &
",document.Security." & lstNo.ID.ToString() & ");"">"
.Text &= "</td></tr>"
.Text &= "<tr><td>"
.Text &= "<input type=""button"" class=""BoxType42""
value=""Disallow All"" name=""btn" & drvTemp("UserID") & "DA""
onclick=""DisAll(document.Security." & lstYes.ID.ToString() &
",document.Security." &
lstNo.ID.ToString() & ");"">"
.Text &= "</td></tr>"
.Text &= "<tr><td>"
.Text &= "<input type=""button"" class=""BoxType42""
value=""Disallow"" name=""btn" & drvTemp("UserID") & "D""
onclick=""Disallow(document.Security." & lstYes.ID.ToString() &
",document.Security." &
lstNo.ID.ToString() & ");"">"
.Text &= "</td></tr>"
.Text &= "</table>"
End With
Catch ex As Exception
Debug.WriteLine(ex.ToString)
Response.Write("<BR>_______________________<BR>" & ex.ToString &
"<BR>")
Response.Flush()
End Try
End If