ConnectionString="Data Source=.;
Initial Catalog=Test;UserID=sa;Password=sa"
SelectCommand="SELECT [EmployeeID], [EmployeeName],
[JoiningDate], [Salary], [DepartmentID] FROM [Employee]">
Displaying Views of Data (Part II)
[ 200 ]
Formatting Data Using the FormView Control
As you can see from the figure given earlier, the employee data displayed in the
FormView control is not properly formatted. In this section we will learn how we
can use custom formatting to display data in the FormView control in a properly
formatted manner.
To ensure that the FormView control displays a custom text when there are no records
in the control, we will use the property called EmptyDataText shown as follows:
EmptyDataText="No Records"
Now, to test whether the above message is displayed, let us bind an empty data
source to the FormView control. We will make the data source empty by changing its
Select statement shown as follows:
ConnectionString="Data Source=.;
Initial Catalog=Test;UserID=sa;Password=sa"
SelectCommand="SELECT [EmployeeID], [EmployeeName],
[JoiningDate], [Salary], [DepartmentID] FROM [Employee] where
1=0">
The above data source is empty as the condition specified 1=0 is always false.
Pages:
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192