Textbox Binding

S

shariffshiraz

[I posted this previously as part of a thread to a related topic, but
did not receive a response so I thought of starting a new thread..]

I am using a FormView, Insert Template. I have 3 textboxes which are
bound. I would like to use a default (static) value in one of the
textboxes.

Here's the (relevant) sample code:

<InsertItemTemplate>


Stamp: <asp:TextBox ID="StampTextBox" runat="server"
Text='<%#Bind("fldStamp") %>'></asp:TextBox><br />


Again, what I would like to do is assign a default/static text "Canada"
to this textbox and bind it to fldStamp


I am fairly new at this and would appreciate your assistance and some
sample code.


Thanks
Shiraz
 
S

Shiraz

Hi Eliyahu

Thanks for your prompt response. What I meant was that I would like to
set the textbox field to "Canada" as you have inidicated correctly in
your code above. I would then like to have this text, on insert, bound
to the database field fldStamp.

Perhaps this will explain my issue:

Two Textboxes - one I would like to enter a value in and bind to the
database, the other I want to use a static value and bind to a
database:

The first is:

<asp:TextBox ID="TextBox1" runat="server"
Text='<%#Bind("fldTextBox") %>'></asp:TextBox><br />

The second:

<asp:TextBox ID="TextBox2" runat="server" Text="Canada"/>
like in the first example however, I would like this one with the
static text of "Canada" bound to the fldTextbox2 so that when I click
insert, it inserts the value entered in Textbox1 to fldTextbox1 and the
static value of Textbox2 (i.e., Canada) to fldTextbox2

Thanks
Shiraz
 
E

Eliyahu Goldin

Shiraz,

You have a contradiction in your request. To get a default text "Canada" you
need to write
<asp:TextBox ID="StampTextBox" runat="server" Text="Canada"/>
What do you mean by binding if it is already set to a static value? And what
is fldStamp?

Eliyahu
 
E

Eliyahu Goldin

Shiraz,

Term "databinding" refers to cases when you link a web control property to a
datasource and it is used for setting properties. You need something else,
not databinding. You need to write a piece of code that will get the textbox
values, put them in a sql insert statement and execute the insert.

Eliyahu
 
W

will eichert

I found this thread because I'm working with a similar issue. Isn't there some way to, in code, maybe in an event handler, set a value for a bound field? I have a formview with a bunch of fields the user will enter. One of the fields is the user's account and another is the current date, both of which are determined at runtime by code. I'd like to store these values as part of the record when the formview posts. I know how to put a value in the control using a page property, and I know how to bind a control, but I don't know how to get a computed value into the field which will then get stored to the db with the other formview data. I think this is some easy thing that I'm just making difficult. Anyone? I'm using .Net 2.0 Beta.

Thanks,

Will

From http://www.developmentnow.com/g/8_2005_7_0_0_555215/Textbox-Binding.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top