Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I were doing this, I would change the code so that the contents in your click function are in a separate functions so that you can recall it easily from other functions. I would use a strongly typed object instead of a dataset for added symplicity. Also add a couple of string arguments to the "Load Data" function to accept monum and name strings.</p> <p>To find multiples, just check the count of what the database returns (datatable.rows.count or StronglyTypedObject.count)</p> <p>Next, create a invisible dropdownlist control and set it to visible if your row count is > 0.</p> <p>using Linq, binding the dropdownlist is fairly straight forward. Then call the new "load data" event on the onselectedindexchanged event passing the name selected along with the monumber.</p> <p>I will not go into filling a strongly typed object as this question is already asking for alot, but to get you started... The following code example is just that and should not be taken as the actual code you will use.</p> <pre><code>Protected Sub GotMONum_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles GotMO.Click loaddata(monum.text, "") end sub protected sub loaddata(byval monum as string, byval name as string) 'your code here along with the following lines after: Dim MySelectQuery As String = "" myCommand.Parameters.AddWithValue("@MONum", MOTxt.Text) if not string.isnullorempty(name) MySelectQuery = "SELECT Name,ProdLine,NoRods,TieOffs FROM z_md_Outwrap WHERE MONumber = @MONum and Name = @name" mycommand.Parameters.AddWithValue("@Name", Name) else MySelectQuery = "SELECT Name,ProdLine,NoRods,TieOffs FROM z_md_Outwrap WHERE MONumber = @MONum " End If 'again, instead using a dataset, convert it to a list(of StronglyTypedObject) if StronglyTypedObject.count &gt; 0 then dropdownlist.visible = true dim dropdownlistcontents = (from a in StronglyTypedObject.AsEnumerable _ Select a.Name).Distinct dropdownlist.datasource = dropdownlistcontents dropdownlist.databind end if end sub Protected Sub DDL_OnSelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) handles dropdownlist.selectedindexchanged loaddata(monum.text, "dropdownlist.selectedvalue") end sub </code></pre> <p>Hopefully this gets you on your way... - Mutek</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload