Книга: C# 2008 Programmer
Displaying Publisher's Name
Displaying Publisher's Name
As Figure 17-15 shows, the publisher's ID appears in the GridView
control under the pub_id
field. It would be helpful to the user if the publisher's name displayed instead of its ID. To do that, switch to the source view of Default.aspx
and within the <asp:GridView>
element, replace the following element:
<asp:BoundField
DataField="pub_id"
HeaderText="pub_id"
SortExpression="pub_id"/>
with this:
<asp:TemplateField
HeaderText="Publisher">
<ItemTemplate>
<%#Eval("publisher.pub_name")%>
</ItemTemplate>
</asp:TemplateField>
Essentially, this changes the header for the publisher column in the GridView to Publisher
, and the values are now derived from the publisher.pub_name
property of the DataClassesDataContext
class.
Press F5 to debug the application again to see the publishers' names instead of the publishers' IDs (see Figure 17-16).
Figure 17-16
- Data Binding Using the GridView Control
- Modeling Databases Using LINQ to SQL
- Displaying Titles from a Selected Publisher
- namespace-uri()
- 11.5. Функции getservbyname и getservbyport
- Displaying Interface Statistics
- 11.19. Функции gethostbyname_r и gethostbyaddr_r
- Метод GetTempName
- Unreal Tournament 2004
- Displaying Free and Used Memory with free
- Name-Based Virtual Hosts
- How Nameservers Store DNS Structure Information