How to do this: Binding a TextBox that is always empty

Last post 04-11-2008 2:25 AM by koendc. 3 replies.

Sort Posts:

  • How to do this: Binding a TextBox that is always empty

    04-10-2008, 10:53 AM
    • Member
      1 point Member
    • koendc
    • Member since 04-10-2008, 10:43 AM
    • Posts 2

    Hi,

     
    It seems easy but I can't work out how to do this...

    I am putting binding a TextBox in a Gridview:

     

                        <asp:TextBox ID="TextBoxZorgeenheidNieuw" runat="server" style="display:none" Text='<%# Bind("zorgeenheid_naam") %>'></asp:TextBox>

    What I want:

    • In Edit Mode: the textbox is always empty, even if a value is available
    • If the textbox is filled in, the value is passed trough.
    • Using the Bind() function

    What I tried

    Bind("module_naam", "")

     
    Then the value was still visible 

    Please help me out! 

  • Re: How to do this: Binding a TextBox that is always empty

    04-10-2008, 11:25 AM
    • Contributor
      6,802 point Contributor
    • pixelsyndicate
    • Member since 07-04-2003, 12:56 PM
    • W. MI transplant in N. TX
    • Posts 1,201

    If you haven't already done so, verify that your select and edit queries are correct.  I have had similar trouble previously when I modified my gridview/formview after it's initial auto-creation by the datasource I was using.  I had to go and recreate the datasource and then bind it to the gridview, which fixed lots of stuff for me.

    Please click 'Mark as Answer' if my reply has assisted you.

    "A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools." ~ Douglas Adams

    http://wildobson.com
  • Re: How to do this: Binding a TextBox that is always empty

    04-10-2008, 11:25 AM
    Answer
    • All-Star
      86,764 point All-Star
    • ecbruck
    • Member since 12-30-2005, 7:39 PM
    • Des Moines, IA
    • Posts 9,209
    • Moderator
      TrustedFriends-MVPs

    You can use the Bind statement, but if you want the TextBox to be empty in the EditItemTemplate, then within the RowDataBound event, you'll have to retrieve a reference to this TextBox, and clear it out yourself. There's no data-binding expression I know of that will allow you this flexibility.

    Thanks, Ed

    Microsoft MVP - ASP/ASP.NET

  • Re: How to do this: Binding a TextBox that is always empty

    04-11-2008, 2:25 AM
    • Member
      1 point Member
    • koendc
    • Member since 04-10-2008, 10:43 AM
    • Posts 2

    Thank you for your reply.

    This is what I tried not to do :) But as there is no other possibility, I will use your suggestion. Thanks a lot!

Page 1 of 1 (4 items)