Click here to Skip to main content
15,921,336 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an <asp:formview xmlns:asp="#unknown"> that is bound to an SQL Database, and, I am trying to figure out how to read an entry from the FormView (through SQL), and, translate its value to a variable, which is then going to be used in an SQL Update Statement.

Moreover, the textboxes should switch from readonly = false to readonly = true. The sequence of events from a user point of view is explained within the screenshots; source code is available here.

Unfortunately I could not use the same FormView for SQL Statements, because of a problem with the buttons on the form, that could not be displayed within <formview>, although it would have been ideal to use the commands used within the <formview> element.

:confused:
Posted

FormView is basically used to display the values of a single record from a data source.

The controls in the ItemTemplate will be rendered only after binding a data source to the FormView control.
In the BindFormView() method, you didn't bind any data source to the FormView control. Therefore myFormView.FindControl("myTextbox") returns always nothing.

Try after data binding to the FormView. It will return the Textbox control.
 
Share this answer
 
HI
You can read the entry from the formview as shown below for TextBox control

TextBox txtPaidAmount = (TextBox)FormView.FindControl(txtTextBox1);
 
Share this answer
 
Comments
jon-80 1-Sep-10 15:29pm    
FindControl doesn't seem to work with TextBoxes embedded within a FormView control.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900