一个关于datagrid排序的问题(在线等!)
我写了一个存储过程:
CREATE Proc ceocio_GetBookList
(
@TID int,
@Author nvarchar(50),
@Bname nvarchar(50),
@orderby nvarchar(50)
)
as
declare @sql varchar(100)
if @orderby= ' ' set @orderby = 'ID '
set @sql = 'select * from Book Order by '+ @orderby + ' desc '
.......
我想使用datagrid的排序的功能
我使用的是三层结构
但是,现在不知道怎么定义接口,以及具体的处理过程
在没有排序功能是我的接口是这样写的:
DataTable GetBookList(int TID,string Author,string Bname);
处理过程是这样的:
public DataTable GetBookList(int TID,string Author,string Bname)
{
return GetDataTable( "book_GetBookList ",GetBookList_Parameters(TID,Author,Bname));
}
private SqlParameter [] GetBookList_Parameters(int TID,string Author,string Bname)
{
SqlParameter[] p=
{
SqlHelper.MakeInParam( "@TID ",SqlDbType.Int,4,TID),
SqlHelper.MakeInParam( "@Author ",SqlDbType.NVarChar,50,Author),
SqlHelper.MakeInParam( "@Bname ",SqlDbType.NVarChar,50,Bname),
};
return p;
}
请高手指点一下
我该怎么写呢?
------解决方案--------------------搂住换成VS2005就可以很方便的GridView的排序功能,只要设定好你的SqlDataSoure,指向你的存储过程,参数定义好,就可以排序
------解决方案--------------------接口类定义:
DataTable GetBookList(int TID,string Author,string Bname);
处理过程类:
public DataTable GetBookList(int TID,string Author,string Bname)
{
return GetDataTable( "book_GetBookList ",GetBookList_Parameters(TID,Author,Bname));
}
private SqlParameter [] GetBookList_Parameters(int TID,string Author,string Bname)
{
SqlParameter[] p=
{
SqlHelper.MakeInParam( "@TID ",SqlDbType.Int,4,TID),
SqlHelper.MakeInParam( "@Author ",SqlDbType.NVarChar,50,Author),
SqlHelper.MakeInParam( "@Bname ",SqlDbType.NVarChar,50,Bname),
};
return p;
}
实现接口类:
1.声明接口类 如:aa
2.
public DataTable GetBookList(int TID,string Author,string Bname)
{
return aa.GetBookList(TID,Author,Bname);
}
调用:
1.声明实现接口类 如:bb
DataGrid1.DataSource = bb.GetBookList(TID,Author,Bname);
DataGrid1.Bind();
------------------------------
表达能力有限,基本是这个意思
------解决方案--------------------楼上的空架子