Results 1 to 3 of 3

Thread: Evaluate Datalist Controls

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Evaluate Datalist Controls

    I've got this code to go through all textboxes on a webform & look to see if each of them have a blank value. How can I use something like this to go through all item textbox controls created in/by a datalist please???
    VB Code:
    1. For each ctlWebFormControl in page.Controls
    2.     If (ctlWebFormControl.GetType.ToString.
    3.     Equals("System.Web.UI.WebControls.TextBox")) then
    4.         If not(CType(ctlWebFormControl, _
    5.         System.Web.UI.WebControls.TextBox).Text  = "")) then_
    6.             ' Something Here
    7.         End if
    8.     End If
    9. Next
    Thanks!!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Lively Member
    Join Date
    Oct 2002
    Location
    Los Angeles, CA
    Posts
    73
    Internal part of the loop is fine, external should look something like:

    Code:
    foreach(DataListItem dli in MyDataList.Items)
    {
       foreach(Control ctl in dli.Controls)
      {
         //here is your logic
      }
    }

  3. #3

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Ah thanks for that, forgot I had this one posted here. Incase anyone else tries to do this in future I used this code:
    VB Code:
    1. For intLoopCounter = 1 to (DatalistName.Items.count)                           
    2.     If not(CType(DatalistName.Items(intLoopCounter).Controls(1), _
    3.     System.Web.UI.WebControls.TextBox).Text = "") then
    4.         ' Some Code here...
    5.     End If
    6. Next intLoopCounter
    Many thanks for the reply though Split, much appriciated!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width