我遇到了一个简单的问题,但我不知道问题出在哪里:/所以我的GridView
我正在使用ObjectDataSource
自定义分页,如本教程http://www.codedigest.com/Articles/ASPNET/180_Custom_GridView_Paging_with_ObjectDataSource_Control_with_ASPNet_20.aspx
这是我的aspx标记:
<asp:ObjectDataSource ID="ObjectDataSource2"
runat="server"
onselecting="ObjectDataSource2_Selecting"
EnablePaging="true"
SelectCountMethod="GetItemsCount"
SelectMethod="BindItems"
StartRowIndexParameterName="startRowIndex"
MaximumRowsParameterName="maximumRows"
TypeName="eSova.Utilities.RecordUtilities"
>
调用的方法:
public static DataTable BindItems(int category,int search,int startRowIndex,int maximumRows)
{
DataTable table = new DataTable();
using (SqlConnection connection = new SqlConnection())
{
ConnectionUtilities.OpenConnection(connection);
SqlTransaction transaction = connection.BeginTransaction();
try
{
SqlCommand command = new SqlCommand("GetItems",connection,transaction);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@RowIndex", SqlDbType.Int, 4).Value = startRowIndex;
command.Parameters.Add("@MaxRows", SqlDbType.Int, 4).Value = maximumRows;
SqlDataAdapter adapter = new SqlDataAdapter(command);
adapter.Fill(table);
transaction.Commit();
}
catch
{
transaction.Rollback();
}
}
return table;
}
我的存储过程工作正常并返回表中的所有项目。
但是当我分析代码时,我在返回时得到了断点,而表变量没有记录。我不知道问题在哪里。
更新:
create proc [dbo].[GetItems](@RowIndex int,@MaxRows int)
as
declare @StartRows int
declare @EndRow int
set @StartRows=(@RowIndex+1)
set @EndRow=(@StartRows+@MaxRows)
select *
from ( select id, name, filepath, descript, itemlanguage,
filetypeid, ROW_NUMBER() over (ORDER by id)as row FROM Items)as NumberesItems
where row between @StartRows and @EndRow
答案 0 :(得分:0)
您的connectionstring为空。