Hello. I have a page with one formview [formview1] displaying information from a database such as stock number, make, model etc.
I then have another formview [formview2] on the same page that I use to insert in to a DB.
On formview2, I want to pre-populate 3 of the fields with information displayed in formview1. What ive tried to do is write c# code to get the text from formview in the 'OnDataBound' event of Formview2. It doesn't work. I have to admit I'm rubbish at c#, so I need some help.
This is what I've got so far:
public
partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void FormView2_OnLoad(object sender, EventArgs e)
{
if (FormView2.CurrentMode == FormViewMode.Insert)
{
((TextBox)FormView1.FindControl("StockNoInterestedTextBox")).Text = ((TextBox)FormView1.FindControl("Stock")).Text;
}
}
}
===============
AND this in my aspx page:
FormView1:
<
asp:TextBox ID="stock" runat="server" Text='<% Eval("StockNumber") %>'></asp:TextBox>
FormView2:
<
asp:TextBox ID="StockNoInterestedTextBox" runat="server" Text='<%# Bind("StockNoInterested") %>'>
</asp:TextBox>
<asp:AccessDataSource OnLoad="FormView2_OnLoad" ... >
==============
When I run that, it says that "The name 'FormView2' does not exist in the current context", but I can't see what Im doing wrong.
Can someone post me some coding that allows me to take text from FormView1 TextBox Stock and automatically put it in FormView2 TextBox StockNoInterestedTextBox
Thanks In Advance, Phil