Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Keep the Bind while setting the text of a textbox in FormView

Reply
Thread Tools

Keep the Bind while setting the text of a textbox in FormView

 
 
Michael
Guest
Posts: n/a
 
      06-02-2009
I have one textbox in a FormView 'Insert Template' and it is bound to the
'FirstName' in a database. What I am trying to do is set the text to equal
the text from a hidden field named hiddenFirstName and not lose its binding
to the 'FirstName' field in the database. I then want to be able to insert
it into the database after clicking the 'Insert' text.

The code to assign the hidden value to the FormView's 'FirstName' textbox is
below. I've tried two different methods to accomplish the task and both have
resulted in errors. Below that is the code for the FormView.

Thanks

---------Beginning of Script Code-------------

<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

my_hiddenFirstName.Value = Request.Form("hiddenFirstName")

(Method 1) - > FirstNameTextBox.Text = my_hiddenFirstName.Value ----->
(This generates an error)

(Method 1) - > (TextBox)FormView1.FindControl(FirstNameTextBox).T ext =
my_hiddenFirstName.Value -----> (This generates an error)

End Sub

</script>

---------End of Script Code-------------



---------Beginning of FormView Code-------------

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"

DataSourceID="AccessDataSource1" DefaultMode="Insert" AllowPaging="True">

<asp:FormView ID="FormView1" runat="server" DataKeyNames="ID"

DataSourceID="AccessDataSource1" DefaultMode="Insert" AllowPaging="True">

<InsertItemTemplate>

FirstName:

<asp:TextBox ID="FirstNameTextBox" runat="server"

Text='<%# Bind("FirstName") %>' />

<br />

<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"

CommandName="Insert" Text="Insert" />

&nbsp;<asp:LinkButton ID="InsertCancelButton" runat="server"

CausesValidation="False" CommandName="Cancel" Text="Cancel" />

</InsertItemTemplate>

</asp:FormView>

<asp:AccessDataSource ID="AccessDataSource1" runat="server"

DataFile="~/App_Data/customers.mdb"

InsertCommand="INSERT INTO [Customers] ([FirstName], [ID]) VALUES (?, ?)" >

<InsertParameters>

<asparameter Name="FirstName" Type="String" />

<asparameter Name="ID" Type="Int32" />

</InsertParameters>

</asp:AccessDataSource>

---------End of FormView Code-------------








 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How keep python socket alive for ever by setting Keep alive flag. hisan Python 1 06-25-2012 05:30 PM
confused by boost::bind & boost::lambda::bind XHengDF@gmail.com C++ 0 05-29-2007 04:37 AM
Keep the format of MultiLine TextBox.Text =?Utf-8?B?ZnJhbms=?= ASP .Net 3 08-16-2006 07:44 PM
Keep the format of MultiLine TextBox.Text frank ASP .Net Web Controls 0 08-15-2006 03:30 PM
Using a data-bind dropdownlist to populate another data-bind dropdownlist mr2_93 ASP .Net 1 10-02-2005 05:07 PM



Advertisments