codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Adding Dynamic Controls and Accessing their values  sroszko at 17:57 on Monday, March 28, 2005
 

I am creating a page that basically has a dropdown list and a bunch of checkboxes. It is a basic user securty and options page. The DDL is the user and the checkboxes are the items the user has access to.

The checkboxes are created dynamically from SQL query that determines the security items and if the user has access to them. But because they are dynamic controls I'm having trouble creating them at the right place in the page creation.

If I understand correctly, the dynamic checkboxes need to be created in the page_load to be able to access them on the postback to get their values. Works nice, but it seems that in page_load I do not have access to the choice in the ddl from an autopostback.

I've tries to strip down my example here:


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
FillUsers()
End If

Me.lblWarning.Text += Me.ddlUsers.SelectedValue.ToString 'get old value not newly selected value

'cannot get current user from ddl to ShowSecurityContent
'If intUserID <> 0 Then ShowSecurityContent(Me.ddlUsers.SelectedValue.ToString)
End Sub

'------------------------------------------------------------------

Private Sub ddlUsers_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlUsers.SelectedIndexChanged
arrUserID = Split(Me.ddlUsers.SelectedValue, "!")
intUserID = CInt(arrUserID(0))
strUserID = arrUserID(1).ToString

If Me.ddlUsers.SelectedIndex > 0 Then
'can add it this way, but then I cannot access the values of the dynamic checkboxes on save
'ShowSecurityContent(intUserID)
End If
End Sub




In a nutshell....

Autopostback DDL of users
Use selected user to generate dynamic list of checkbox controls
Save button to update user security depending on checked/unchecked boxes


Am I making sense? Sounds pretty easy but the order of page events and what can be accessed is throughing me I think.


Thanks,

-Steve












CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
//








Recent Forum Threads
•  perl script help needed
•  onChange issue
•  perl remote execution
•  Chat application
•  How to send multiple perameters in SOAP request.
•  Java code for Insert picture on the table in spreadsheet
•  Re: Problem with concatenation
•  how to genrates the crystal report by sending a id at runtime
•  help me


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2007