what it wrong with this code

Discussion in 'ASP .Net' started by =?Utf-8?B?TWlrZQ==?=, Oct 5, 2004.

  1. I going through all the checkboxes in my datalist to get the value (checked
    or not checked) and it keeps returning false even if its checked.

    Dim I As Long
    For I = 0 To datalist.Items.Count - 1
    Dim CurrentCheckBox As CheckBox
    CurrentCheckBox = datalist.Items(I).FindControl("checkbox")
    Response.Write("Item(" & I & "): " &
    CurrentCheckBox.Checked.ToString() & "<br>")
    'Response.Redirect("webform1.aspx?I=" & I & "&value=" &
    CurrentCheckBox.Checked.ToString() & "|")
    Next
     
    =?Utf-8?B?TWlrZQ==?=, Oct 5, 2004
    #1
    1. Advertising

  2. It seems to be that since each control has to have a unique name that this
    wouldn't find but one checkbox control - the one named "checkbox". I would
    loop through the controls in the datalist determine if the current control is
    a checkbox then verify if it's checked or not. This syntax probably isn't
    right but you should get the idea.

    Dim obj as Object
    foreach obj in Datalist.Controls
    if obj.GetType = "checkbox" then
    if CType(obj, checkbox).Checked Then
    'do something
    End If
    end if
    next

    "Mike" wrote:

    > I going through all the checkboxes in my datalist to get the value (checked
    > or not checked) and it keeps returning false even if its checked.
    >
    > Dim I As Long
    > For I = 0 To datalist.Items.Count - 1
    > Dim CurrentCheckBox As CheckBox
    > CurrentCheckBox = datalist.Items(I).FindControl("checkbox")
    > Response.Write("Item(" & I & "): " &
    > CurrentCheckBox.Checked.ToString() & "<br>")
    > 'Response.Redirect("webform1.aspx?I=" & I & "&value=" &
    > CurrentCheckBox.Checked.ToString() & "|")
    > Next
    >
    >
     
    =?Utf-8?B?RU5JWklO?=, Oct 5, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. walala
    Replies:
    3
    Views:
    2,267
    Ralf Hildebrandt
    Sep 10, 2003
  2. willem oosthuizen

    What is wrong with the following code?

    willem oosthuizen, Oct 10, 2003, in forum: VHDL
    Replies:
    9
    Views:
    1,355
  3. Matthew
    Replies:
    7
    Views:
    867
    Priscilla Walmsley
    Jan 7, 2005
  4. David. E. Goble
    Replies:
    9
    Views:
    507
    David. E. Goble
    Feb 2, 2005
  5. kiran
    Replies:
    12
    Views:
    1,219
    Scott Sauyet
    Dec 7, 2011
Loading...

Share This Page