FineUI 官方论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

本论坛已关闭(禁止注册、发帖和回复)
请移步 三石和他的朋友们

FineUI首页 WebForms - MVC & Core - JavaScript 常见问题 - QQ群 - 十周年征文活动

FineUI(开源版) 下载源代码 - 下载空项目 - 获取ExtJS - 文档 在线示例 - 版本更新 - 捐赠作者 - 教程

升级到 ASP.NET Core 3.1,快、快、快! 全新ASP.NET Core,比WebForms还简单! 欢迎加入【三石和他的朋友们】(基础版下载)

搜索
查看: 4390|回复: 5
打印 上一主题 下一主题

使用TwinTriggerBox的一个问题

[复制链接]
跳转到指定楼层
楼主
发表于 2012-5-18 21:40:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我在grid的Toolbar里面有一个TwinTriggerBox,用来搜索数据使用
点击事件如下:
protected void ttbxMyBox2_Trigger2Click(object sender, EventArgs e)
    {
        searchKey = tb_searchKey.Text.ToString().Trim();
        BindGrid();
        //Alert.Show(searchKey);
    }
    protected void ttbxMyBox2_Trigger1Click(object sender, EventArgs e)
    {
        tb_searchKey.Text = "";
        searchKey = "";
        Grid1.PageIndex = 0;
        BindGrid();
    }

程序的获取数据分页程序如下:
private void BindGrid()
    {
        // 1.设置总项数
        Grid1.RecordCount = GetTotalCount();
        // 2.获取当前分页数据
        DataSet table = GetPagedDataTable(Grid1.PageIndex, Grid1.PageSize);
        // 3.绑定到Grid
        Grid1.DataSource = table;
        Grid1.DataBind();
    }
    private int GetTotalCount()
    {
        sqlstring = "select count(id)  from KcCustom";
        int totalcount = Convert.ToInt32(SqlHelper.ExecuteScalar(SqlHelper.connectionString, CommandType.Text, sqlstring));
        return totalcount;
    }
    private DataSet GetPagedDataTable(int pageIndex, int pageSize)
    {
        DataSet source;
        int pageindex = pageIndex;
        int pagesize = pageSize;
        if (pagesize <= 0) { pagesize = 30; }
        if (pageindex < 0) { pageindex = 0; }
        if (!string.IsNullOrEmpty(searchKey))
        {
            SqlParameter[] cs4 = new SqlParameter[1];
            cs4[0] = new SqlParameter("@searchKey", searchKey);
            sqlstring = "select top " + pagesize + " id,customId,customName,customMobile,customAdd,customBz,customType,jizhangMax,tixingMoney,customLock from KcCustom where customName=@searchKey";
            //if (pageindex > 0)
            //{
            //    sqlstring = sqlstring + " and id>(select max (id) from (select top ((" + pageindex + ")*" + pagesize + ") id from KcCustom order by id) as T) order by id";
            //}
            source = SqlHelper.ExecuteDataset(SqlHelper.connectionString, CommandType.Text, sqlstring, cs4);
        }
        else
        {
            sqlstring = "select top " + pagesize + " id,customId,customName,customMobile,customAdd,customBz,customType,jizhangMax,tixingMoney,customLock from KcCustom where 1=1";
            if (pageindex > 0)
            {
                sqlstring = sqlstring + " and id>(select max (id) from (select top ((" + pageindex + ")*" + pagesize + ") id from KcCustom order by id) as T) order by id";
            }
            source = SqlHelper.ExecuteDataset(SqlHelper.connectionString, CommandType.Text, sqlstring);
        }
        
        return source;
    }
    protected void Grid1_PageIndexChange(object sender, ExtAspNet.GridPageEventArgs e)
    {
        Grid1.PageIndex = e.NewPageIndex;
        BindGrid();
    }
点击搜索后会出现如下错误
消息: 'undefined' 为空或不是对象
行: 1
字符: 73184
代码: 0
URI: http://localhost/WebResource.axd?d=7OVFSIZ3yBcL8zot75-qFGOzjP-pQ9OwmI30n5dWnCwNudpmO2N8PkN3EMab7nf_us8cDRysBjGpEkCcAkwQT3LmzHHDt3zQRo2QFd1zT2AZ8Jz4wWQYtCoV2xVuxECq1UxqWayUHRcqlxtG0y_LHQ2&t=634719409400000000

请问是什么原因呀,弄了很久都没弄好

沙发
 楼主| 发表于 2012-5-18 21:46:41 | 只看该作者
如果不输入关键字是可以正常显示grid数据的
板凳
 楼主| 发表于 2012-5-19 21:27:06 | 只看该作者
哪位可以帮帮忙呢
地板
发表于 2012-5-19 21:35:21 来自手机 | 只看该作者
火君子二少爷 发表于 2012-5-19 21:27
哪位可以帮帮忙呢

如果你能写个重现问题的简单页面,离解决就不远了
5#
 楼主| 发表于 2012-5-19 23:43:34 | 只看该作者
继续挖掘发现到绑定数据到grid的时候table都是有数据的,但是Grid1.DataBind();并没有把数据显示到grid中。
6#
 楼主| 发表于 2012-5-20 09:57:35 | 只看该作者
问题解决,原来的GetTotalCount();里面获得的数据数量不一致造成。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|FineUI 官方论坛 ( 皖ICP备2021006167号-1 )

GMT+8, 2024-9-28 12:15 , Processed in 0.045456 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表