看到這里,我們已經感覺到了“簡單”,但是,在實際的應用中,像這種直接顯示一個表的情況是很少的。所以,我們需要其他更多的功能。最直接的,我們需要Select語句的返回結果。
<%@ Register TagPrefix="Super" Namespace="Superexpert.Data"
Assembly="Superexpert.SuperDataGrid" %>
<Super:SuperDataGrid
ConnectionString="Server=localhost;UID=sa;pwd=secret;database=Northwind"
CommandText="Select ProductName, CategoryName
From Products, Categories Where Products.CategoryID=Categories.CategoryID"
Runat="Server" />
具體效果請看:
http://www.superexpertcontrols.com/superdatagrid/samples/sample2.aspx
以上代碼返回Select語句的結果。在這里,我們見到一個新的屬性:
CommandText:和Command一樣,就是Select語句;
。、數據排序
在DataGrid中,數據排序雖然簡單,但是代碼還是不少。我們現在來看SuperDataGrid中怎樣給數據排序:
<%@ Register TagPrefix="Super" Namespace="Superexpert.Data"
Assembly="Superexpert.SuperDataGrid" %>
<form runat="Server">
<Super:SuperDataGrid
ConnectionString="Server=localhost;UID=sa;pwd=secret;database=Pubs"
TableName="Titles"
EnableSorting="True"
Runat="Server" />
</form>
具體效果請看:
http://www.superexpertcontrols.com/superdatagrid/samples/sample3.aspx
仔細看以上代碼,其實就是設置了一個EnableSortinga屬性為真。也就是打開排序功能。需要仔細注意的一點,要將SuperDataGrid包括在Form中。
。、數據分頁
在ASP中,很多朋友會為分頁煩惱,現在,我們看看SuperDataGrid中怎樣分頁:
<%@ Register TagPrefix="Super" Namespace="Superexpert.Data"
Assembly="Superexpert.SuperDataGrid" %>
<form runat="Server">
<Super:SuperDataGrid
ConnectionString="Server=localhost;UID=sa;pwd=secret;database=pubs"
TableName="Titles"
EnablePaging="True"
PageSize="3"
PagerStyle-Mode="NumericPages"
Runat="Server" />
</form>
具體效果請看:
http://www.superexpertcontrols.com/superdatagrid/samples/sample4.aspx
我們來看看SuperDataGrid的幾個新屬性:
EnablePaging:首先,我們當然要打開數據分頁;
PageSize:和DataGrid一樣,每頁數據顯示的條數;
PagerStyle-Mode:和DataGrid一樣,頁碼顯示方式;
文章來源于領測軟件測試網 http://www.kjueaiud.com/