?
Solved

How to retrieve data from the selected row from a Dropdown DataWindow

Posted on 2002-06-28
3
Medium Priority
?
5,776 Views
Last Modified: 2013-12-26
I have the following lines of code:

string ls_school_name
integer     li_school_code

li_school_code = dw_school.GetItemNumber(dw_school.GetRow(),'school_code')
ls_school_name = dw_school.GetItemString(dw_school.GetRow(),'school_name')


The problem is the when I issue the GetRow() function, it always returns 1.  How do I get it to return the ROW that the user selected in the DropDown Datawindow?

dw_school is the name of the datawindow control that contains the dropdown data window.  Also, when I use the function dw_school.GetSelectedRow(0) it returns 0, even though the user has selected an item in the dropdown datawindow.  Do I need to reference the DataWindow Child somehow, and if so how?

Another peculiarity is that when I specify:
li_school_code = dw_school.GetItemNumber(1,'school_code')

It returns the school code value for the item the user "selected", but not the value for ROW 1, as it should.  School Code is defined as the DataColumn.  If I issue the same function but for a string which is defined as the DisplayColumn, then I don't get the school name the user selected but the correct name for that Row, for Row one, which is what should be returned.  Is this a bug with PowerBuilder 6.5?

0
Comment
Question by:amollsde
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 4

Expert Comment

by:Bhatti
ID: 7121352
When you placed a dropdowndatawindow in the column of the datawindow then you set the two values to this column, Data value & Display value. You can' write the GetItemString() if it is an Integer value.

Use GetChild() funtion to get the display value.

//Declare variable (Instance or Local up to you)
Datawindowchild ldwc_child

dw_1.GetChild("column_name", ldwc_child)
ldwc_child.SetTransObject(sqlca)
//You can retrieve the ldwc_child
ldwc_child.Retrieve()

//REMEMBER do not declare the retrieve values for child-datawindow.

ldwc_child.GetItemString(ldwc_child.GetRow(), "Column_name")
//Name of the column have the string value

Which datawindow you want to retrieve after getting the value from dropdowndatawindow?

Please let me know to solve it .


Best regards

Bhatti
0
 
LVL 1

Accepted Solution

by:
levr earned 400 total points
ID: 7123597
Let's say 'school_code' is a column in DataWindow 'dw_school'
and 'school_code' is DropDown DataWindow
and this DropDown DataWindow has two columns: 'school_code' and 'school_name'
and you need both values for selected 'school_code'

string ls_school_name
integer li_school_code
Datawindowchild ldwc_child
integer li_row

li_school_code = dw_school.GetItemNumber(dw_school.GetRow(),'school_code')

// get the reference to Child DW as Bhatti advised
dw_school.GetChild('school_code', ldwc_child)

// find the row
li_row = ldwc_child.GetRow()
// or
li_row = dwc_child.Find("'school_code' = li_school_code")

// and get the value
ls_school_name = ldwc_child.GetItemString(li_row,'school_name')

About your questions:

GetRow() returns 1 because it referring to main DW not Child, that has only one row
GetSelectedRow() returns 0 because you didn't select any row in this DW (you select in Child!)
Only display value could be accessed directly
I don't see any PB bugs in this situation, just use Child DW technique
0
 

Author Comment

by:amollsde
ID: 7125287
Lev,

Thank you, thank you, thank you!  You've been a lifesaver. This is the second, VERY precise answer you've given me.  I really appreciate your clarity when responding.  I've aways been able to take your solution, make a slight modification to my script and it's worked everytime.
I really appreciate it!

Alecia
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question