J
Johnny §õ«¶¿« \(Microsoft MVP for ASP.NET\)
The following code is from the online tutorial but it doesn't run on my CTP
build I've just installed.
The first problem is, ImageField doesn't have a public DataField field. Ok,
I removed this line.
The second problem is that "the @EmployeeID column can not be found." Hmmm,
could any one help me verify if the program happens on your side?
BTW, I didn't install SQL 2005. I still use SQL 2000. Can it be the cause of
the problems?
<table cellpadding="10">
<tr>
<td valign="top">
<asp:GridView
ID="MasterGridView"
DataSourceID="MasterSource"
AutoGenerateColumns="false"
DataKeyNames="EmployeeID"
CellPadding="5"
SelectedRowStyle-BackColor="#eeeeee"
Runat="Server">
<Columns>
<asp:TemplateField HeaderText="Employee">
<ItemTemplate>
<asp:LinkButton CommandName="Select" Runat="Server">
<%# Eval("LastName") %>, <%# Eval("FirstName") %>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
<td valign="top">
<aspetailsView
DataSourceID="DetailsSource"
AutoGenerateRows="false"
CellPadding="5"
FieldHeaderStyle-Font-Bold="true"
FieldHeaderStyle-HorizontalAlign="Right"
Runat="Server">
<Fields>
<asp:ImageField DataField="Photo" HeaderText="Photo:" />
<asp:BoundField DataField="LastName"
HeaderText="Last Name:" />
<asp:BoundField DataField="FirstName"
HeaderText="First Name:" />
<asp:BoundField DataField="Extension"
HeaderText="Extension:" />
</Fields>
</aspetailsView>
</td>
</tr>
</table>
<asp:SqlDataSource
ID="MasterSource"
EnableCaching="true"
CacheDuration="600"
ConnectionString=
"Server=localhost;database=Northwind;Trusted_Connection=true"
SelectCommand="SELECT * FROM Employees"
Runat="Server" />
<asp:SqlDataSource
ID="DetailsSource"
EnableCaching="true"
CacheDuration="600"
ConnectionString=
"Server=localhost;database=Northwind;Trusted_Connection=true"
SelectCommand="SELECT * FROM Employees"
FilterExpression="EmployeeID=@EmployeeID"
Runat="Server">
<FilterParameters>
<asp:ControlParameter
Name="EmployeeID"
ControlID="MasterGridView"
PropertyName="SelectedValue" />
</FilterParameters>
</asp:SqlDataSource>
build I've just installed.
The first problem is, ImageField doesn't have a public DataField field. Ok,
I removed this line.
The second problem is that "the @EmployeeID column can not be found." Hmmm,
could any one help me verify if the program happens on your side?
BTW, I didn't install SQL 2005. I still use SQL 2000. Can it be the cause of
the problems?
<table cellpadding="10">
<tr>
<td valign="top">
<asp:GridView
ID="MasterGridView"
DataSourceID="MasterSource"
AutoGenerateColumns="false"
DataKeyNames="EmployeeID"
CellPadding="5"
SelectedRowStyle-BackColor="#eeeeee"
Runat="Server">
<Columns>
<asp:TemplateField HeaderText="Employee">
<ItemTemplate>
<asp:LinkButton CommandName="Select" Runat="Server">
<%# Eval("LastName") %>, <%# Eval("FirstName") %>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
<td valign="top">
<aspetailsView
DataSourceID="DetailsSource"
AutoGenerateRows="false"
CellPadding="5"
FieldHeaderStyle-Font-Bold="true"
FieldHeaderStyle-HorizontalAlign="Right"
Runat="Server">
<Fields>
<asp:ImageField DataField="Photo" HeaderText="Photo:" />
<asp:BoundField DataField="LastName"
HeaderText="Last Name:" />
<asp:BoundField DataField="FirstName"
HeaderText="First Name:" />
<asp:BoundField DataField="Extension"
HeaderText="Extension:" />
</Fields>
</aspetailsView>
</td>
</tr>
</table>
<asp:SqlDataSource
ID="MasterSource"
EnableCaching="true"
CacheDuration="600"
ConnectionString=
"Server=localhost;database=Northwind;Trusted_Connection=true"
SelectCommand="SELECT * FROM Employees"
Runat="Server" />
<asp:SqlDataSource
ID="DetailsSource"
EnableCaching="true"
CacheDuration="600"
ConnectionString=
"Server=localhost;database=Northwind;Trusted_Connection=true"
SelectCommand="SELECT * FROM Employees"
FilterExpression="EmployeeID=@EmployeeID"
Runat="Server">
<FilterParameters>
<asp:ControlParameter
Name="EmployeeID"
ControlID="MasterGridView"
PropertyName="SelectedValue" />
</FilterParameters>
</asp:SqlDataSource>