Combobox problems

Results 1 to 2 of 2

Thread: Combobox problems

  1. #1
    Join Date
    Dec 1969

    Default Combobox problems

    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&#039;t changed. The textfields etcetera are changed, but the comboboxes haven&#039;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 =&#062; refresh screen =&#062; show actual asset<BR>if we change the combobox containing all the assets =&#062; 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&#039;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&#039;t changed.<BR><BR>Any ideas?

  2. #2
    Join Date
    Dec 1969

    Default RE: Possible solution

    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 &#060;Edit/Add/Delete WebForm&#062; 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> <BR> &#039;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 &#060;asp:ListItem Selected="True"&#062; ??<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=&#039;David&#039;") &#039;Find the Row wanted for edit only<BR><BR>ObjRow(0).Item("FirstName") = "John" &#039;Extra one record into Row(0)<BR>objRow(0).Item("Address") = "12 Orchard Road" &#039;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")) &#039;SQL statement must be sorted by PARTTYPE<BR> dv1.Sort = "PARTTYPE"<BR><BR>1) cblINDEXNO = dv1.Find(Trim(mvPARTTYPE)) &#039;Will return the index in the DataView<BR> <BR> &#060;asp:CheckBoxList id="SELPARTS" DataSource=&#039;&#060;%# GETCHKKLIST("OPTBYFILE","ZZ") %&#062;&#039;<BR> SelectedIndex=&#039;&#060;%# GETCHKLIST("OPTBYFILE", Container.DataItem("PARTSLIST").ToString) %&#062;&#039;<BR> DataValueField=&#039;dbfPARTTYPE&#039; DataTextField=&#039;dbfPARTDESC&#039; runat="server" &#062;<BR> &#060;/asp:CheckBoxList&#062;<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)) &#039;Must Trim if from DropDownList<BR> <BR> Can do a for each Object.item to get Multiple selected items<BR> <BR> &#060;asp:CheckBoxList id="SELPARTS" DataSource=&#039;&#060;%# GETCHKKLIST("OPTBYHTAB","ZZ") %&#062;&#039;<BR> SelectedIndex=&#039;&#060;%# GETCHKLIST("OPTBYHTAB", Container.DataItem("PARTSLIST").ToString) %&#062;&#039;<BR> DataValueField=&#039;Key&#039; DataTextField=&#039;Value&#039; runat="server" &#062;<BR> &#060;/asp:CheckBoxList&#062; <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><BR><BR><BR>Tip 7: Request Selected Checkboxes <BR><BR>In any ASP application, you have several checkboxes, all with the same name:<BR>&#060;input type="checkbox"name="foo"<BR> value="..."&#062;<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>&#060;%a =split(Request.Form("foo"),",") %&#062;<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’s split function and get<BR>an easily manageable structure, such as an array.<BR> <BR>The same code won’t work in ASP.NET if you use the &#060;asp:checkbox&#062; server control.<BR>To make it work, stick with the HtmlInputCheckBox control and write code such as this: <BR>&#060;input type="checkbox"runat="server"<BR> name="foo"value="..."&#062;<BR><BR>Even though the asp:checkbox and input type="checkbox" server tags evaluate to the<BR> same HTML code, ASP.NET ensures unique IDs and names for the tags output by asp:checkbox<BR> and any other control in the &#060;asp&#062; namespace. <BR><BR>This sure works well. Thanks<BR><BR><BR>

Posting Permissions

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