How to Bind Object Properties to a FormView
The "FormView" class is part of the .NET framework "System.Web.UI.WebControls" namespace. A "FormView" object displays a record from a data source by utilizing a custom template. Binding properties to your "FormView" object customizes the style and settings for the "FormView" according to your specific data and program's needs. Properties for the "FormView" object include its width, id, height, header, caption and colors. Create a "FormView" object and then bind its properties individually.
Instructions
-
-
1
Open your source file with an editor, such as Microsoft Visual Studio.
-
2
Create a new "FormView" object in your function. In C# this is done by adding the following code:
FormView myFormView = new FormView();
Replace "myFormView" with the name of your "FormView."
-
-
3
Set the "FormView" object's properties in your function using the "myFormView." syntax. In C# this is done with the following code:
myFormView.ID = "My FormView";
myFormView.HeaderText = "My Data";
myFormView.RowStyle.BackColor = System.Drawing.Color.Silver;
myFormView.PagerStyle.BackColor = System.Drawing.Color.LightBlue;
myFormView.HeaderStyle.BackColor = System.Drawing.Color.LightBlue;
myFormView.AllowPaging = true;Use the same code syntax to change any other properties in the "FormView" class definition, such as "Caption," "Font," "GridLines" and "ToolTip."
-
4
Save the file, compile and run the program to bind the properties to your "FormView" object.
-
1