The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Help with dynamicaly populating listbox
Posted: 03 Feb 08 3:10 PM
|
On form load and when fields are changed I need to dynaicaly populate 3 list boxes. Below is my code form the lan client. I cant think of where their may be an example in the OOTB client.
Thanks, Brian
START SAMPLE Sub aceClassExitControl(Sender)
Dim strSQL Dim objCon Dim objRS Dim intCount
set objCon = Application.GetNewConnection
' strSQL = "SELECT TOP 1 ITEMID FROM QUOTE_ITEM " strSQL = "SELECT ITEMID FROM ITEM " strSQL = strSQL & "WHERE ITEM_LEVEL = '" & aceLevel.Text & "' " strSQL = strSQL & "AND ITEM_FAMILY = '" & aceFamily.Text & "' " strSQL = strSQL & "AND ITEM_CLASS = '" & aceClass.Text & "' " 'Do not work in MSDE strSQL = strSQL & "AND rownum = 1 "
set objRS = objCon.Execute(strSQL) intCount = objRS.RecordCount If intCount <> 0 then txtFCSItemID.Text = objRS.Fields("ITEMID").Value Else MsgBox "Invalid selections. Please try again." aceLevel.Text = "" aceFamily.Text = "" aceClass.Text = "" aceLevel.SetFocus End If objRS.Close set objRS = Nothing objCon.Close set objCon = Nothing
End Sub
END SAMPLE |
|
|
| |
|
Re: Help with dynamicaly populating listbox
Posted: 04 Feb 08 8:22 AM
|
Hey Brian,
Ok, so first you have your comboboxes that are hosted on your smart parts. These comboboxes have an onchange action that you can associate some body of work to. So on the controlling combobox add a change action c#. What this will do is embed the code into the smart part. You can then refer to the other child controls by name. When the change occurrs on the control you can update the list associated with the target control. The easies example would be
targetControl.Items.Clear(); targetControl.Items.Add("Item 1"); targetControl.Items.Add("Item 2");
now since you want to populate the list based on the database I would more then likely do something like;
protected void Type_ChangeAction(object sender, EventArgs e) { Sage.Platform.Data.IDataService _dataService = ParentWorkItem.Services.Get(); System.Data.DataTable table = new System.Data.DataTable(); string sql = "Select Account from Account where Account like 'AB%'"; using (System.Data.OleDb.OleDbConnection conn = (System.Data.OleDb.OleDbConnection)_dataService.GetConnection()) { conn.Open(); System.Data.OleDb.OleDbDataAdapter adapter = new System.Data.OleDb.OleDbDataAdapter(sql, conn); adapter.Fill(table); }
choiceCombo.DataTextField = "Account"; choiceCombo.DataValueField = "Account"; choiceCombo.DataSource = table; choiceCombo.DataBind(); }
Mark
|
|
|
| |
|
Re: Help with dynamicaly populating listbox
Posted: 04 Feb 08 11:56 AM
|
Moved thread to more appropriate forum (from "SalesLogix 7.2 Web Client & Application Architect" forum to "SalesLogix Scripting & VBScript" forum) |
|
|
|
Re: Help with dynamicaly populating listbox
Posted: 05 Feb 08 10:45 AM
|
Ryan,
these postings should be in web IMHO. Also
there is a problem with the code getting the IDataService from the service container. Use the following line please
Sage.Platform.Data.IDataService _dataService = ParentWorkItem.Services.Get<Sage.Platform.Data.IDataService>();
Mark |
|
|
|
Re: Help with dynamicaly populating listbox
Posted: 05 Feb 08 10:59 AM
|
Did I misunderstand what Brian was asking? It wouldn't be the first time
I saw Brian's question and sample code, which is definitely code for the windows client (ADO recordsets and VBScript). I assumed he was asking about that for the LAN client. Is he asking how to do that in the web client then?
I've moved it back - sorry! |
|
|
|
Re: Help with dynamicaly populating listbox
Posted: 05 Feb 08 11:04 AM
|
No worries.
Yes he is working on the web client and was using the lan client code as a reference on how he did it there and how would/could he do it in the web client. I provided a sample in the OnChange action where he could do some databinding to the list using the IDataService as an example without having to go through the entity model to get the lookup values.
Make Sense?
Mark
|
|
|
|
Re: Help with dynamicaly populating listbox
Posted: 10 May 12 11:08 AM
|
fiogf49gjkf0d Mark,
I'm trying to use this in a C# code snippet inside the app arch with the combobox on a quick form, but I'm having some trouble.
First, it's not recognizing the "ParentWorkItem.Services" portion ('ParentWorkItem' does not exist in the current context).
Also, when trying to define combobox.DataSource and DataBind, there's aren't definitions for them.
Any help would be greatly appreciated, I'm very new to the web client/app arch & can't quite wrap my head around the changes from the LAN.
Thanks in advance!
Samantha |
|
|
|