2013-01-31 40 views
0

我需要能夠查看來自SQL數據庫的數據,並選擇要打印的特定行(稍後處理)。 考慮到我不需要在任何時候編輯數據,而我所需要的只是帶有一個複選框的數據,額外的控制是什麼?要使用哪種數據控件?

回答

2

最有可能是GridView

<asp:SqlDataSource id="CustomersSource" 
    SelectCommand="SELECT CustomerID, CompanyName, FirstName, LastName FROM SalesLT.Customer" 
    ConnectionString="<%$ ConnectionStrings:AWLTConnectionString %>" 
    runat="server"/> 

<asp:GridView id="CustomersGridView" 
    DataSourceID="CustomersSource" 
    AutoGenerateColumns="False" 
    EmptyDataText="No data available." 
    AllowPaging="True" 
    runat="server" DataKeyNames="CustomerID"> 
    <Columns> 
     <asp:BoundField DataField="CustomerID" HeaderText="CustomerID" 
      InsertVisible="False" ReadOnly="True" SortExpression="CustomerID" /> 
     <asp:BoundField DataField="CompanyName" HeaderText="CompanyName" 
      SortExpression="CompanyName" /> 
     <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
      SortExpression="FirstName" /> 
     <asp:BoundField DataField="LastName" HeaderText="LastName" 
      SortExpression="LastName" /> 
    </Columns> 
</asp:GridView>