Windows Develop Bookmark and Share   
 index > Windows Forms General > What is the differnece?
 

What is the differnece?

Hi everybody;

There is a checklist. When I run it with debugging, the return values from checklist are correct.But without debugging, although I check 3 things, only one of them return true.Why?

romork  Wednesday, March 21, 2007 8:30 AM
romork wrote:

Hi everybody;

There is a checklist. When I run it with debugging, the return values from checklist are correct.But without debugging, although I check 3 things, only one of them return true.Why?

If you are referring to a CheckBoxList, are you looping thru the items or just checking the selected value of the entire list? If you check the selected value of the entire list it will, in my experience, return the first selected value only. This is an example:

aspx page HTML source;
<asp:CheckBoxList ID="cblMediaType" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" AutoPostBack="True"></asp:CheckBoxList>

VB code;
For iIndex = 0 To Me.cblMediaType.Items.Count - 1
If Me.cblMediaType.Items(iIndex).Selected = True Then
Me.lblYouSelected.Text = Me.lblYouSelected.Text & Me.cblMediaType.Items(iIndex).Value.ToString & ","
End If
Next

If, however you do this;
Me.cblMediaType.SelectedValue

You will get only the first selected value, even though a debug watch may show each of the selected values, the program only deals with one upon execution.

Or did I completely miss the problem you are having?

bucketofsquid  Wednesday, March 21, 2007 9:25 PM
What is a checklist? Show us some code please.
nobugz  Wednesday, March 21, 2007 12:32 PM
romork wrote:

Hi everybody;

There is a checklist. When I run it with debugging, the return values from checklist are correct.But without debugging, although I check 3 things, only one of them return true.Why?

If you are referring to a CheckBoxList, are you looping thru the items or just checking the selected value of the entire list? If you check the selected value of the entire list it will, in my experience, return the first selected value only. This is an example:

aspx page HTML source;
<asp:CheckBoxList ID="cblMediaType" runat="server" RepeatColumns="3" RepeatDirection="Horizontal" AutoPostBack="True"></asp:CheckBoxList>

VB code;
For iIndex = 0 To Me.cblMediaType.Items.Count - 1
If Me.cblMediaType.Items(iIndex).Selected = True Then
Me.lblYouSelected.Text = Me.lblYouSelected.Text & Me.cblMediaType.Items(iIndex).Value.ToString & ","
End If
Next

If, however you do this;
Me.cblMediaType.SelectedValue

You will get only the first selected value, even though a debug watch may show each of the selected values, the program only deals with one upon execution.

Or did I completely miss the problem you are having?

bucketofsquid  Wednesday, March 21, 2007 9:25 PM

Hi Romork,

If you have ASP.Net related issues in the future, you can also try posting them at the ASP.Net forum:

http://forums.asp.net/

There are more ASP.Net experts there.

If the issue is not related to ASP.Net, you can further elaborate what CheckList you are referring to.

Ting Wang  Monday, March 26, 2007 9:00 AM

You can use google to search for other answers

Custom Search

More Threads

• problem in FTP download
• detecting key up event
• How do I Highlight the contents of a numericupdown after calling Focus()?
• WebBrowser and BindToMoniker
• Incremental search in GridView by sorted column
• Add usercontrol to toolstrip item collection
• How to Print on a remote Machine
• Plotting of graph in inherited form
• how to leave the focus of a control, when click in a non focusable part of the form
• datagridview Thread problem