|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Getting multi values from a list boxthe selectionmode set to multiselect and the tables are populated correctly with the correct values and text properties. The problem I have is extracting which values are selected in the list. I have the following code that iterates over the list. If the item is selected, I create a parameter, call the stored proc in SQL server to update and move on. No problem. The problem I get is that no listitem in the listbox indicates it is selected, even though I have selected multiple items (or even single items) I can't get anything to show as selected. I have included the web page control code, the binding code and the code to iterate the control. Can anyone see what I am missing. John. List box page code <asp:ListBox ID="lbConditions" runat="server" Height="72px" SelectionMode="Multiple" Width="224px"></asp:ListBox><br /> Code that iterates the list box For Each lstCond As ListItem In lbConditions.Items If lstCond.Selected Then objParam.CreateParameter("EventID", intTripID, DbType.Int32, ParameterDirection.Input) objParam.CreateParameter("ConditionID", lstCond.Value, DbType.Int32, ParameterDirection.Input) objDAL.ExecuteNonQuery("AddEventCondition", objParam) objParam.Clear() End If Next Code that binds the control dtConditions = objDAL.ExecuteDataTable("GetEventConditions", objParam) lbConditions.DataSource = dtConditions lbConditions.DataTextField = "ConditionName" lbConditions.DataValueField = "EventConditionID" lbConditions.SelectionMode = ListSelectionMode.Multiple lbConditions.DataBind() > If lstCond.Selected Then Instead of directly pushing it to parameters, first try to simply print it > > objParam.CreateParameter("EventID", intTripID, DbType.Int32, > ParameterDirection.Input) on the browser (either in a Label or otherewise)... Check if the problem is with getting the values or with the DB-code. -- Happy Hacking, Gaurav Vaish | http://www.mastergaurav.com http://www.edujinionline.com http://articles.edujinionline.com/webservices ------------------- That makes no sense whatsoever. As I explained, the listboxes are populated
correctly, the problem is none of the items in the listbox are recognized as selected, it has nothing to do with the database. John "Gaurav Vaish (www.EduJiniOnline.com)" <gaurav.vaish.nospam@nospam.gmail.com> wrote in message Show quoteHide quote news:u15JKzp4GHA.1196@TK2MSFTNGP02.phx.gbl... >> If lstCond.Selected Then >> >> objParam.CreateParameter("EventID", intTripID, DbType.Int32, >> ParameterDirection.Input) > > Instead of directly pushing it to parameters, first try to simply print it > on the browser (either in a Label or otherewise)... > Check if the problem is with getting the values or with the DB-code. > > > -- > Happy Hacking, > Gaurav Vaish | http://www.mastergaurav.com > http://www.edujinionline.com > http://articles.edujinionline.com/webservices > ------------------- > > > correctly, the problem is none of the items in the listbox are recognized Have you tried checking the raw-request that is sent to sever on postback?> as selected, it has nothing to do with the database. Request.InputStream ... read all contents into a file and see if the data is being currently sent to the server. -- Happy Hacking, Gaurav Vaish | http://www.mastergaurav.com http://www.edujinionline.com http://articles.edujinionline.com/webservices -------------------
Uploading big files
GridView Update Not Working missing ellipsis in editor asp.net 2 report problem with 3-tier design GridView Nested - Is it Possible? ASP.Net 2.0 Validation Groups & IValidator Controls. How to use Socket Connection Authentication in ASP.NET 2.0 Role of the web.config file with UserControls [2.0] Assign access key to control ? |
|||||||||||||||||||||||