When
you bind such a data source to the FormView control with its EmptyDataText
property set, the text gets displayed in place of the records which would otherwise
have been displayed if the data source contained data. Here is the output on execution:
The JoiningDate and the Salary fields displayed in the FormView control shown
in the earlier section were not properly formatted. Here is how you can use the
Bind() method in the markup code in the .aspx file to format the display of these
fields in the control.
Joining Date:
Text='<%# Bind("JoiningDate","{0:d}") %>'>Salary:
Chapter 7
[ 201 ]
Note how we have used the data format string in the second parameter to the
Bind() method.
We can also use a DropDownList control within the FormView control to display the
department names with the department to which the specific employee belongs as
the selected department in the DropDownList. The markup code follows:
DataSourceID="SqlDataSource2" DataTextField="DepartmentName"
DataValueField="DepartmentID" SelectedValue='<%#
Eval("DepartmentID") %>'/>
To customize paging, we can use the PagerTemplate of the FormView control with
LinkButtons and appropriate texts on them.
Pages:
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193