mypeoxypori
New Member
We have an update function that allows us to update certain data in the database. The thing is that when we select an item in a combobox, the entire screen shows the details of the item, including some comboboxes (1 of them is containing operating systems for instance) and these comboboxes are shown with the value that resides in the database. For instance, if an item has win95 as os, we want the combobox to show win95 as the selected item. This works, but if we select another item, and we afterwards select the first item again, then the comboboxes aren't changed. The textfields etcetera are changed, but the comboboxes haven't. <BR><BR>The code we are using : <BR><BR> oListItemOs = cboOS.Items.FindByValue(dsAsset.Tables(0).Rows(0). Item("OS").ToString)<BR> If Not oListItemOs Is Nothing Then oListItemOs.Selected = True Else cboOS.SelectedIndex = 0<BR><BR>This function is called on 2 occasions : <BR><BR>if we press the update button => refresh screen => show actual asset<BR>if we change the combobox containing all the assets => we want to show the proper values of the currently selected asset. <BR><BR>I tried setting the comboboxes autopostback to true, but that doesn't seem to change a thing. When I run the app in debugmode, I do see that the findbyvalue function gives me the right id of the os, but the combobox just hasn't changed.<BR><BR>Any ideas?Some possible solution<BR><BR>How to initialize the multiple selected indexes values<BR>(ie more than 1) in a CheckBoxList or DropDownLIst [WITHIN] a DATAGRID Control<BR>from a Dynamic Generated CheckboxList<BR><BR>I would like to use it when editing a record in a <Edit/Add/Delete WebForm> and<BR>ticking the 3 selected checkBoxList Check boxes of the existing EDITing record field.<BR><BR>A good solution for basic CheckBoxList<BR> <BR>http://www.123aspx.com/resdetail.aspx?res=552 <BR>http://askasp.net/articles.asp?ArtID=69 'On Dynamic ListBox<BR><BR>If CheckBoxList is outside of Datagrid and Not dynamically generated<BR>can be initialize by doing this (From Pg125 of Wrox Beginning ASP.NET Using VB.NET)<BR><BR>Determine the selected item and do following init<BR><BR> CheckBoxList1.Items(1).Selected = 0<BR> CheckBoxList1.Items(2).Selected = 1<BR> CheckBoxList1.Items(3).Selected = 1<BR><BR>Answer may have something with setting <asp:ListItem Selected="True"> ??<BR><BR>----------------------------------------------------------------<BR>To get the Index of a Selected Row in a Dataset or Dataview<BR><BR>Dim objTable as DataTable = objDataSet.Table("Books")<BR><BR>Dim objRow() as DataRow<BR><BR>objRow = objTable.Select("FirstName='David'") 'Find the Row wanted for edit only<BR><BR>ObjRow(0).Item("FirstName") = "John" 'Extra one record into Row(0)<BR>objRow(0).Item("Address") = "12 Orchard Road" 'change to "John"<BR><BR>-----------------------------------------------------------------<BR>Selected Index used to determine the SelectedIndex= ??<BR>of a Dynamic DropDownList or CheckBoxList within a DataGRid Control<BR>using a File(DataView), SortedLIst() or Array() as DataSource<BR>Sorry For single selection only. Any solution for Multiple select ???<BR>------------------------------------------------------------------<BR><BR> Dim mvPARTTYPE as String = "PT001"<BR> Dim dv1 As New DataView(ds.Tables("PARTSFILE")) 'SQL statement must be sorted by PARTTYPE<BR> dv1.Sort = "PARTTYPE"<BR><BR>1) cblINDEXNO = dv1.Find(Trim(mvPARTTYPE)) 'Will return the index in the DataView<BR> <BR> <asp:CheckBoxList id="SELPARTS" DataSource='<%# GETCHKKLIST("OPTBYFILE","ZZ") %>'<BR> SelectedIndex='<%# GETCHKLIST("OPTBYFILE", Container.DataItem("PARTSLIST").ToString) %>'<BR> DataValueField='dbfPARTTYPE' DataTextField='dbfPARTDESC' runat="server" ><BR> </asp:CheckBoxList><BR> <BR> [DataValueField and DataTextField] changed to actual FieldName of DataView<BR> <BR> <BR> *** To get the index of a SortedList() or HashTable()<BR><BR>2) cblINDEXNO = hsTABLE.IndexOfKey(Trim(dvPARTTYPE)) 'Must Trim if from DropDownList<BR> <BR> Can do a for each Object.item to get Multiple selected items<BR> <BR> <asp:CheckBoxList id="SELPARTS" DataSource='<%# GETCHKKLIST("OPTBYHTAB","ZZ") %>'<BR> SelectedIndex='<%# GETCHKLIST("OPTBYHTAB", Container.DataItem("PARTSLIST").ToString) %>'<BR> DataValueField='Key' DataTextField='Value' runat="server" ><BR> </asp:CheckBoxList> <BR><BR><BR> *** To get Index of ArrayList()<BR><BR>3) cblINDEXNO = arArray.IndexOf(dvPARTTYPE)<BR><BR>================================================== ===================<BR>Easiest Best Solution ":- refer to 10 tips from limbt @<BR><BR>http://communities.msn.com.sg/vsnetsingapore/general.msnw<BR><BR><BR>Tip 7: Request Selected Checkboxes <BR><BR>In any ASP application, you have several checkboxes, all with the same name:<BR><input type="checkbox"name="foo"<BR> value=http://aspmessageboard.com/archive/index.php/"..."><BR><BR>You can get the corresponding values of the checkboxes that have been selected<BR> upon form posting with a single line of code: <BR><%a =split(Request.Form("foo"),",") %><BR><BR>Request.Form("foo") returns a comma-separated string formed by the value strings<BR>of all checked items. You pass this string to the VBScript