M
Michael
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).Text =
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" />
<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-------------
'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).Text =
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" />
<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-------------