R
Ryan Ternier
Thanks for the previous help guys!
I got my list box issue working, but now i'm trying to loop through all the
items in my page.
I want to find each listbox, once I do i strip the ID down to find what I
need so I can populate a DB.
lstTest is dim'd as a ListBox, and I thought I could just do:
For Each lstTest in Me.Controls to find each listbox, but I keep getting the
error:
System.InvalidCastException: Specified cast is not valid.
at ActionItems2._0.ItemSecurity.btnSubmit_Click(Object sender, EventArgs e)
in C:\Development\glimpse\ActionItems\ActionItems\ItemSecurity.aspx.vb:line
222
What's the easiest way of accomplishing this. I want to do most of it in
..NET to get my knowledge up.
I could accomplish it in JScript, but that's not helping my .NET
Thanks!
Try
For Each lstTest In Me.Controls
astrListID = (lstTest.ClientID.ToString.Split("_"))
'If the string = lstY, the listbox where people are allowed to edit,
then continue.
If Left(astrListID(2), 4) = "lstY" Then
strID = astrListID(2).Remove(0, 4) 'strID is now the UserID
lstRowItem = New ListItem
For Each lstRowItem In lstTest.Items
'Grab the Security ID from the DB where this user resides.
strSQL = "Select SecurityID from tblItemSecurity where
UserID = " & strID & " AND type = 'item' AND TypeID = " &
intTypeID
cmdSecurity.CommandText = strSQL
intSecurityID = cmdSecurity.ExecuteScalar
'Now with that Security ID, let's start populate the item
field DB based on that security idish
strSQL = "INSERT into tblItemFieldSecurity (SecurityID,
FieldID) values(" & intSecurityID & ", " & lstRowItem.Value
& ")"
cmdSecurity.CommandText = strSQL
cmdSecurity.ExecuteNonQuery()
Next
End If
Next
Catch ex As Exception
I got my list box issue working, but now i'm trying to loop through all the
items in my page.
I want to find each listbox, once I do i strip the ID down to find what I
need so I can populate a DB.
lstTest is dim'd as a ListBox, and I thought I could just do:
For Each lstTest in Me.Controls to find each listbox, but I keep getting the
error:
System.InvalidCastException: Specified cast is not valid.
at ActionItems2._0.ItemSecurity.btnSubmit_Click(Object sender, EventArgs e)
in C:\Development\glimpse\ActionItems\ActionItems\ItemSecurity.aspx.vb:line
222
What's the easiest way of accomplishing this. I want to do most of it in
..NET to get my knowledge up.
I could accomplish it in JScript, but that's not helping my .NET
Thanks!
Try
For Each lstTest In Me.Controls
astrListID = (lstTest.ClientID.ToString.Split("_"))
'If the string = lstY, the listbox where people are allowed to edit,
then continue.
If Left(astrListID(2), 4) = "lstY" Then
strID = astrListID(2).Remove(0, 4) 'strID is now the UserID
lstRowItem = New ListItem
For Each lstRowItem In lstTest.Items
'Grab the Security ID from the DB where this user resides.
strSQL = "Select SecurityID from tblItemSecurity where
UserID = " & strID & " AND type = 'item' AND TypeID = " &
intTypeID
cmdSecurity.CommandText = strSQL
intSecurityID = cmdSecurity.ExecuteScalar
'Now with that Security ID, let's start populate the item
field DB based on that security idish
strSQL = "INSERT into tblItemFieldSecurity (SecurityID,
FieldID) values(" & intSecurityID & ", " & lstRowItem.Value
& ")"
cmdSecurity.CommandText = strSQL
cmdSecurity.ExecuteNonQuery()
Next
End If
Next
Catch ex As Exception