具体代码如下
<asp:SqlDataSource
id="srcEmployeeDetails"
ConnectionString="<%$ ConnectionStrings:Employees %>"
SelectCommand="SELECT * FROM Employees
WHERE FirstName=@FirstName AND LastName=@LastName"
Runat="server">
<SelectParameters>
<asp:ControlParameter
Name="FirstName"
ControlID="grdEmployees"
PropertyName='SelectedDataKey("FirstName")' />
<asp:ControlParameter
Name="LastName"
ControlID="grdEmployees"
PropertyName='SelectedDataKey("LastName")' />
</SelectParameters>
</asp:SqlDataSource>
貌似是PropertyName='SelectedDataKey("FirstName")'这个地方用()和[]都没有错误,这是为什么呢?这个地方应该是个索引器,索引器不是应该用中括号么?
你应该还有一个gridview的吧
对的,但是我觉得跟这个没什么关系,就没贴上
@微澜:
PropertyName 主要是看给这个属性附上了值,最后是怎么操作的
@chenping2008: GridView 中代码是这样的
<asp:GridView
id="grdEmployees"
DataSourceID="srcEmployees"
DataKeyNames="LastName,FirstName"
AutoGenerateSelectButton="True"
SelectedRowStyle-CssClass="selectedRow"
Runat="server" EnableModelValidation="True" AllowSorting="True" />