Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7626035
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:16:17+00:00 2026-05-31T05:16:17+00:00

I know how to display data in a List control using dataProvider but what

  • 0

I know how to display data in a List control using dataProvider but what about control that don’t have dataProvider e.g. TextInput, Label contorl?

I know how to display data in a List control using dataProvider but what about control that don’t have dataProvider e.g. TextInput, Label contorl?

    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"
            creationComplete="view1_creationCompleteHandler(event)" >

        <fx:Script>
            <![CDATA[


import mx.collections.ArrayCollection;
                import mx.events.FlexEvent;

                private var db:File = File.userDirectory.resolvePath("users01.db");
                private var conn:SQLConnection;
                private var Stmt:SQLStatement;

                [Bindable]private var dp:ArrayCollection = new ArrayCollection();

                protected function view1_creationCompleteHandler(event:FlexEvent):void          {
                    conn = new SQLConnection();
                    conn.addEventListener(SQLEvent.OPEN, openHandler);
                    conn.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    conn.openAsync(db);
                }
                private function openHandler(event:SQLEvent):void {
                    log.text += "Database opened successfully";
                    conn.removeEventListener(SQLEvent.OPEN, openHandler);
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "CREATE TABLE IF NOT EXISTS UserTable (" + 
                        "userId INTEGER PRIMARY KEY AUTOINCREMENT," +
                        "userLevel," + 
                        "firstName TEXT," + "lastName TEXT)";
                    Stmt.addEventListener(SQLEvent.RESULT, createResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                private function createResult(event:SQLEvent):void {
                    log.text += "\nTable created";
                    conn.removeEventListener(SQLEvent.RESULT, createResult);
                    showResult();
                }
                private function errorHandler(event:SQLErrorEvent):void {
                    log.text += "\nError message: " +  event.error.message;
                    log.text += "\nDetails: " +  event.error.details;
                }
                private function insertResult(event:SQLEvent):void {
                    log.text += "\nInsert completed";
                    showResult();
                }
                private function showResult():void  {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "SELECT * FROM UserTable";
                    Stmt.addEventListener(SQLEvent.RESULT, selectResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                private function selectResult(event:SQLEvent):void {
                    log.text += "\nSelect completed";
                    var result:SQLResult = Stmt.getResult();
                    listBox.dataProvider=new ArrayCollection(result.data);
                }
                protected function Save(event:MouseEvent):void          {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "INSERT INTO UserTable (firstName, lastName, userLevel)" +
                        "VALUES (:firstName, :lastName, :userLevel)";
                    Stmt.parameters[":firstName"] = firstName.text;
                    Stmt.parameters[":lastName"] = lastName.text;
                    Stmt.parameters[":userLevel"] = ID.text;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                protected function Delete(event:MouseEvent):void    {

                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text="DELETE FROM UserTable WHERE lastName = ?";
                    Stmt.parameters[0] = listBox.selectedItem.lastName;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                    trace("record deleted");
                }
                protected function Update(event:MouseEvent):void            {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "UPDATE UserTable SET " +
                        "firstName=:firstName, " +
                        "lastName = :lastName " +
                        "WHERE userLevel = :userLevel2";
                    Stmt.parameters[":firstName"] = firstName.text;
                    Stmt.parameters[":lastName"] = lastName.text;
                    Stmt.parameters[":userLevel2"] = ID.text;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
            ]]>
        </fx:Script>


        <s:Label text="FirstName" top="8" left="5"/>
        <s:TextInput id="firstName" left="-1" top="36" width="233" height="80"/>

        <s:Label text="LastName" top="0" left="248"/>
        <s:TextInput id="lastName" left="231" top="32" width="224" height="84"/>

        <s:Label text="ID" top="0" left="483"/>
        <s:TextInput id="ID" left="463" top="32" width="167" height="84"/>

        <s:Button left="10" top="151" width="121" height="54" label="Save" click="Save(event)"/>
        <s:Button left="139" top="151" width="146" height="54" label="Delete" click="Delete(event)" enabled="{listBox.selectedIndex != -1}"/>
        <s:Button left="293" top="151" width="147" height="54" label="Update" click="Update(event)"/>

        <s:List id="listBox" x="-1" y="265" width="641" height="167" itemRenderer="UserRenderer"></s:List>

        <s:TextArea id="log" x="0" bottom="4" width="100%" height="221"/>
    </s:View>

Try to use {dp.ID} and {dp.getItemAt(0).ID} on TextInput but nothing being display?

Thanks.

How to make TextInput id=”firstName” able to display the SQL data?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T05:16:18+00:00Added an answer on May 31, 2026 at 5:16 am

    I think you should just assign the value to the TextInput object or else use another bindable string variable to bind to that you then assign in the method. You should see a warning in during compilation that it won’t be able to use bindings on that line when you do the getItemAt I believe. dp.ID wouldn’t make sense as the dataprovider is typed as an array collection and the collection itself has no ID property. Bindings essentially work by creating an event dispatch any time the setter for a property is called, behind the scenes the mxml compiler will add a setter and getter for the property you mark bindable and automatically dispatch an event when the setter is called and the value has changed. That event is captured and is set to whatever things you “bound” to it. I copied your code below and modified:

    EDIT (pasted your code from above again, two options from what I see below):

    Option 1 based on what I originally saw:

    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"
            creationComplete="view1_creationCompleteHandler(event)" >
    
        <fx:Script>
            <![CDATA[
    
    
                import mx.collections.ArrayCollection;
                import mx.events.FlexEvent;
    
                private var db:File = File.userDirectory.resolvePath("users01.db");
                private var conn:SQLConnection;
                private var Stmt:SQLStatement;
    
                [Bindable]private var dp:ArrayCollection = new ArrayCollection();
    
                protected function view1_creationCompleteHandler(event:FlexEvent):void          {
                    conn = new SQLConnection();
                    conn.addEventListener(SQLEvent.OPEN, openHandler);
                    conn.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    conn.openAsync(db);
                }
                private function openHandler(event:SQLEvent):void {
                    log.text += "Database opened successfully";
                    conn.removeEventListener(SQLEvent.OPEN, openHandler);
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "CREATE TABLE IF NOT EXISTS UserTable (" + 
                        "userId INTEGER PRIMARY KEY AUTOINCREMENT," +
                        "userLevel," + 
                        "firstName TEXT," + "lastName TEXT)";
                    Stmt.addEventListener(SQLEvent.RESULT, createResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                private function createResult(event:SQLEvent):void {
                    log.text += "\nTable created";
                    conn.removeEventListener(SQLEvent.RESULT, createResult);
                    showResult();
                }
                private function errorHandler(event:SQLErrorEvent):void {
                    log.text += "\nError message: " +  event.error.message;
                    log.text += "\nDetails: " +  event.error.details;
                }
                private function insertResult(event:SQLEvent):void {
                    log.text += "\nInsert completed";
                    showResult();
                }
                private function showResult():void  {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "SELECT * FROM UserTable";
                    Stmt.addEventListener(SQLEvent.RESULT, selectResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                private function selectResult(event:SQLEvent):void {
                    log.text += "\nSelect completed";
                    var result:SQLResult = Stmt.getResult();
                    listBox.dataProvider=new ArrayCollection(result.data);
                    if(result.data.length>0)  //I ADDED THIS
                        firstName.text = result.data[0].firstName;  //I ADDED THIS
                }
                protected function Save(event:MouseEvent):void          {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "INSERT INTO UserTable (firstName, lastName, userLevel)" +
                        "VALUES (:firstName, :lastName, :userLevel)";
                    Stmt.parameters[":firstName"] = firstName.text;
                    Stmt.parameters[":lastName"] = lastName.text;
                    Stmt.parameters[":userLevel"] = ID.text;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                protected function Delete(event:MouseEvent):void    {
    
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text="DELETE FROM UserTable WHERE lastName = ?";
                    Stmt.parameters[0] = listBox.selectedItem.lastName;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                    trace("record deleted");
                }
                protected function Update(event:MouseEvent):void            {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "UPDATE UserTable SET " +
                        "firstName=:firstName, " +
                        "lastName = :lastName " +
                        "WHERE userLevel = :userLevel2";
                    Stmt.parameters[":firstName"] = firstName.text;
                    Stmt.parameters[":lastName"] = lastName.text;
                    Stmt.parameters[":userLevel2"] = ID.text;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
            ]]>
        </fx:Script>
    
    
        <s:Label text="FirstName" top="8" left="5"/>
        <s:TextInput id="firstName" left="-1" top="36" width="233" height="80"/>
    
        <s:Label text="LastName" top="0" left="248"/>
        <s:TextInput id="lastName" left="231" top="32" width="224" height="84"/>
    
        <s:Label text="ID" top="0" left="483"/>
        <s:TextInput id="ID" left="463" top="32" width="167" height="84"/>
    
        <s:Button left="10" top="151" width="121" height="54" label="Save" click="Save(event)"/>
        <s:Button left="139" top="151" width="146" height="54" label="Delete" click="Delete(event)" enabled="{listBox.selectedIndex != -1}"/>
        <s:Button left="293" top="151" width="147" height="54" label="Update" click="Update(event)"/>
    
        <s:List id="listBox" x="-1" y="265" width="641" height="167" itemRenderer="UserRenderer"></s:List>
    
        <s:TextArea id="log" x="0" bottom="4" width="100%" height="221"/>
    </s:View>
    

    Option 2 (assuming that you want to bind based on the selectedItem in the list):

    <?xml version="1.0" encoding="utf-8"?>
    <s:View xmlns:fx="http://ns.adobe.com/mxml/2009" 
            xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView"
            creationComplete="view1_creationCompleteHandler(event)" >
    
        <fx:Script>
            <![CDATA[
    
    
                import mx.collections.ArrayCollection;
                import mx.events.FlexEvent;
    
                private var db:File = File.userDirectory.resolvePath("users01.db");
                private var conn:SQLConnection;
                private var Stmt:SQLStatement;
    
                [Bindable]private var dp:ArrayCollection = new ArrayCollection();
    
                protected function view1_creationCompleteHandler(event:FlexEvent):void
                {
                    conn = new SQLConnection();
                    conn.addEventListener(SQLEvent.OPEN, openHandler);
                    conn.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    conn.openAsync(db);
                }
                private function openHandler(event:SQLEvent):void {
                    log.text += "Database opened successfully";
                    conn.removeEventListener(SQLEvent.OPEN, openHandler);
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "CREATE TABLE IF NOT EXISTS UserTable (" + 
                        "userId INTEGER PRIMARY KEY AUTOINCREMENT," +
                        "userLevel," + 
                        "firstName TEXT," + "lastName TEXT)";
                    Stmt.addEventListener(SQLEvent.RESULT, createResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                private function createResult(event:SQLEvent):void {
                    log.text += "\nTable created";
                    conn.removeEventListener(SQLEvent.RESULT, createResult);
                    showResult();
                }
                private function errorHandler(event:SQLErrorEvent):void {
                    log.text += "\nError message: " +  event.error.message;
                    log.text += "\nDetails: " +  event.error.details;
                }
                private function insertResult(event:SQLEvent):void {
                    log.text += "\nInsert completed";
                    showResult();
                }
                private function showResult():void  {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "SELECT * FROM UserTable";
                    Stmt.addEventListener(SQLEvent.RESULT, selectResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                private function selectResult(event:SQLEvent):void {
                    log.text += "\nSelect completed";
                    var result:SQLResult = Stmt.getResult();
                    listBox.dataProvider=new ArrayCollection(result.data);
                    listBox.selectedIndex = 0; //I ADDED THIS
                }
                protected function Save(event:MouseEvent):void          {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "INSERT INTO UserTable (firstName, lastName, userLevel)" +
                        "VALUES (:firstName, :lastName, :userLevel)";
                    Stmt.parameters[":firstName"] = firstName.text;
                    Stmt.parameters[":lastName"] = lastName.text;
                    Stmt.parameters[":userLevel"] = ID.text;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
                protected function Delete(event:MouseEvent):void    {
    
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text="DELETE FROM UserTable WHERE lastName = ?";
                    Stmt.parameters[0] = listBox.selectedItem.lastName;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                    trace("record deleted");
                }
                protected function Update(event:MouseEvent):void            {
                    Stmt = new SQLStatement();
                    Stmt.sqlConnection = conn;
                    Stmt.text = "UPDATE UserTable SET " +
                        "firstName=:firstName, " +
                        "lastName = :lastName " +
                        "WHERE userLevel = :userLevel2";
                    Stmt.parameters[":firstName"] = firstName.text;
                    Stmt.parameters[":lastName"] = lastName.text;
                    Stmt.parameters[":userLevel2"] = ID.text;
                    Stmt.addEventListener(SQLEvent.RESULT, insertResult);
                    Stmt.addEventListener(SQLErrorEvent.ERROR, errorHandler);
                    Stmt.execute();
                }
            ]]>
        </fx:Script>
    
        <!-- I ADDED STUFF HERE -->
        <s:Label text="FirstName" top="8" left="5" />
        <s:TextInput id="firstName" left="-1" top="36" width="233" height="80" text="@{listBox.selectedItem.firstName}" />
    
        <s:Label text="LastName" top="0" left="248"/>
        <s:TextInput id="lastName" left="231" top="32" width="224" height="84"/>
    
        <s:Label text="ID" top="0" left="483"/>
        <s:TextInput id="ID" left="463" top="32" width="167" height="84"/>
    
        <s:Button left="10" top="151" width="121" height="54" label="Save" click="Save(event)"/>
        <s:Button left="139" top="151" width="146" height="54" label="Delete" click="Delete(event)" enabled="{listBox.selectedIndex != -1}"/>
        <s:Button left="293" top="151" width="147" height="54" label="Update" click="Update(event)"/>
    
        <s:List id="listBox" x="-1" y="265" width="641" height="167" itemRenderer="UserRenderer"></s:List>
    
        <s:TextArea id="log" x="0" bottom="4" width="100%" height="221"/>
    </s:View>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a CheckBoxList that displays a list of checkboxes using data from a
I know I can display an ArrayList by using for(i=0;i<data.list.length;i++){ html += data.list[i] +<br
I have some hierarchical data that I need display as a table, can I
How do I display hierarical data in ASP.NET? I have a data source that
What is the best way to display multidimensional data in WPF? I won't know
Does anyone know the display formatter that I would need to add to the
Does anyone know how to display a percentage format based on the locale using
I know that the reminder application should display a badge or sound or kind
I know that in Javascript document.location.href = #my_id tells the browser to display the
I know this one might be easy but I couldn't figure out. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.