web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Can't Clear Textbox.Te...
Power Apps
Answered

Can't Clear Textbox.Text OnSelect in Gallery

(0) ShareShare
ReportReport
Posted on by
Hello,
 
I have a gallery that displays soda stock levels. A textbox defaults to the Display amount, but I want to clear the default value when I select it. I've tried using the OnSelect property with these commands to no avail: TxtBxQty.Text = ""reset(TxtBxQty), and setting the Reset property to True. Nothing seems to work. I also tried UpdateContext but am having a hard time having it default to Gallery.ThisItem. Any help is greatly appreciated!
 
image.png
Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at
    1. Set a variable
    Set(clearItem,TxtBxQty.Text = " ") on
    Onvisible of the screen.
    2. Insert a button or an icon into the Gallery. Then OnSelect of this Icon put the variable name:
    clearItem
  • Verified answer
    v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @animartis ,

    Do you want the textinput display the default value at first, if you click the textinput, clear the default value in the textinput?

    Firstly, let me explain why your solution did not work.

    It is not supported to change the text that the textinput displays by using this kind of formula: 

    TxtBxQty.Text = ""

    You could only change the textinput's Default property to decide what text display in the textinput by default.

    "TxtBxQty.Text" is used to represent the text in the textinput.  It could be used as a "text" data.

     

    Next, could you tell me when you click the textinput whether do you want to make the selected item's textinput blank or all the textinputs blank?

    1、If you want to make all the textinputs blank when you click one textinput, the solution is very easy.

    1)set the TxtBxQty's Default:

     

    If(var,"",ThisItem.Current)

     

    2)set the TxtBxQty's OnSelect:

     

    Set(var,true)

     

    Then, at the beginning the textinput display the Current field value. If you click one textinput, all the textinputs will become blank.

    2265.gif

     2、If you only want to make the selected item's textinput blank after you click the textinput, the solution will be a little complex.

    Because the Textinput's Default property inside the gallery will affect all the textinputs in the gallery. That's also the reason why all the textinputs become blank in the first solution.

    To avoid this problem, you need to use collection.

    Here's my similar test for your reference:

    1)set the screen's OnVisible:

    ClearCollect(collection,fruit11111)
    //fruit11111 is my list name, please replace with your data source name
    create a collection with the data of your data source

    2)set the gallery's Items:

    collection
    //display the collection in the gallery, not the data source

    3)set the textinput's OnSelect:

    Patch(collection,ThisItem,{Current:""})
    //update the selected item's Current field to blank
    please notice that this will not affect the data source's data

    4)set the textinput's Default:

    ThisItem.Current
    //display the Current field in the collection

    In this way, at the beginning the textinput display the original data of the data source, if you click one textinput, the textinput's displaying data will become blank.

    2266.gif

     

     

    Please notice that since in this situation, the gallery 's data source is the collection actually, so all the formulas related to this gallery need to make a little, especially those related to updating records.

    For example: If you use "Gallery1.Selected", I suggest you change to this:

    LookUp(your data source name,ID=Gallery1.Selected.ID)

    "Gallery1.Selected" means the selected item in the collection.

    This formula will return the related item in your data source.

     

     

     

    Best regards,

  • animartis Profile Picture
    on at

    @v-yutliu-msft  This is perfect, thank you! I actually want the latter, where the single box is cleared when selected. This makes total sense. Really appreciate your detailed walk through!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard