问题描述
一个表列包括StudentID,StudentName,StudentPass,Sex,Birthday,Email,score用asp.net编程我想默认显示StudentID,StudentName,StudentPass,Sex,后增加一个详细信息选择时才显示整个列可是点击每个详细信息都显示第一行的数据怎样才能选择每行的详细信息显示对应的信息<%@PageLanguage="VB"AutoEventWireup="false"CodeFile="details.aspx.vb"Inherits="details"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.1//EN""http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>UntitledPage</title></head><body><formid="form1"runat="server"><div><asp:SqlDataSourceID="SqlDataSource1"runat="server"ConflictDetection="CompareAllValues"ConnectionString="<%$ConnectionStrings:pubsConnectionString%>"DeleteCommand="DELETEFROM[authors]WHERE[au_id]=@original_au_idAND[au_lname]=@original_au_lnameAND[au_fname]=@original_au_fnameAND[phone]=@original_phoneAND[address]=@original_addressAND[city]=@original_cityAND[state]=@original_stateAND[zip]=@original_zipAND[contract]=@original_contract"InsertCommand="INSERTINTO[authors]([au_id],[au_lname],[au_fname],[phone],[address],[city],[state],[zip],[contract])VALUES(@au_id,@au_lname,@au_fname,@phone,@address,@city,@state,@zip,@contract)"SelectCommand="SELECT*FROM[authors]"UpdateCommand="UPDATE[authors]SET[au_lname]=@au_lname,[au_fname]=@au_fname,[phone]=@phone,[address]=@address,[city]=@city,[state]=@state,[zip]=@zip,[contract]=@contractWHERE[au_id]=@original_au_idAND[au_lname]=@original_au_lnameAND[au_fname]=@original_au_fnameAND[phone]=@original_phoneAND[address]=@original_addressAND[city]=@original_cityAND[state]=@original_stateAND[zip]=@original_zipAND[contract]=@original_contract"><DeleteParameters><asp:ParameterName="original_au_id"Type="String"/><asp:ParameterName="original_au_lname"Type="String"/><asp:ParameterName="original_au_fname"Type="String"/><asp:ParameterName="original_phone"Type="String"/><asp:ParameterName="original_address"Type="String"/><asp:ParameterName="original_city"Type="String"/><asp:ParameterName="original_state"Type="String"/><asp:ParameterName="original_zip"Type="String"/><asp:ParameterName="original_contract"Type="Boolean"/></DeleteParameters><UpdateParameters><asp:ParameterName="au_lname"Type="String"/><asp:ParameterName="au_fname"Type="String"/><asp:ParameterName="phone"Type="String"/><asp:ParameterName="address"Type="String"/><asp:ParameterName="city"Type="String"/><asp:ParameterName="state"Type="String"/><asp:ParameterName="zip"Type="String"/><asp:ParameterName="contract"Type="Boolean"/><asp:ParameterName="original_au_id"Type="String"/><asp:ParameterName="original_au_lname"Type="String"/><asp:ParameterName="original_au_fname"Type="String"/><asp:ParameterName="original_phone"Type="String"/><asp:ParameterName="original_address"Type="String"/><asp:ParameterName="original_city"Type="String"/><asp:ParameterName="original_state"Type="String"/><asp:ParameterName="original_zip"Type="String"/><asp:ParameterName="original_contract"Type="Boolean"/></UpdateParameters><InsertParameters><asp:ParameterName="au_id"Type="String"/><asp:ParameterName="au_lname"Type="String"/><asp:ParameterName="au_fname"Type="String"/><asp:ParameterName="phone"Type="String"/><asp:ParameterName="address"Type="String"/><asp:ParameterName="city"Type="String"/><asp:ParameterName="state"Type="String"/><asp:ParameterName="zip"Type="String"/><asp:ParameterName="contract"Type="Boolean"/></InsertParameters></asp:SqlDataSource></div><asp:DetailsViewID="DetailsView1"runat="server"AutoGenerateRows="False"DataKeyNames="au_id"DataSourceID="SqlDataSource1"Height="50px"Width="125px"><Fields><asp:BoundFieldDataField="au_id"HeaderText="au_id"ReadOnly="True"SortExpression="au_id"/><asp:BoundFieldDataField="au_lname"HeaderText="au_lname"SortExpression="au_lname"/><asp:BoundFieldDataField="au_fname"HeaderText="au_fname"SortExpression="au_fname"/><asp:BoundFieldDataField="phone"HeaderText="phone"SortExpression="phone"/><asp:BoundFieldDataField="address"HeaderText="address"SortExpression="address"/><asp:BoundFieldDataField="city"HeaderText="city"SortExpression="city"/><asp:BoundFieldDataField="state"HeaderText="state"SortExpression="state"/><asp:BoundFieldDataField="zip"HeaderText="zip"SortExpression="zip"/><asp:CheckBoxFieldDataField="contract"HeaderText="contract"SortExpression="contract"/><asp:CommandFieldShowDeleteButton="True"ShowEditButton="True"ShowInsertButton="True"/></Fields></asp:DetailsView><asp:LinkButtonID="LinkButton1"runat="server"PostBackUrl="~/gridview.aspx">back</asp:LinkButton></form></body></html>这是微软官方ASP.NET.2.0快速入门数据绑定那个教程
解决方案
解决方案二:
将不想显示的列加上Visible="false"然后在点击详细的时候改成true就可以了
解决方案三:
摁.你点击详细信息的时候,把主键传过去.这样就可以看到对应的信息了