PageIndexChanged 不起作用

发布于 2024-09-08 17:21:04 字数 4041 浏览 3 评论 0原文

我正在将 Radgrid 与寻呼机一起使用。单击寻呼机上的下一页编号时,不会显示数据(不绑定数据)。谁能帮我解决这个问题。这是我的代码。

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        if (!IsPostBack)
        {
            Session["SearchRes"] = null;
            if (Session["TaskName"] != null)
                lblTskName.Text = Session["TaskName"].ToString();
            Session["FilColms"] = null;
            Session["SortExp"] = null;
            Session["FilExp"] = null;
            Session["ViewAll"] = null;
            BindGrid();
        }
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

private void BindGrid()
{
    try
    {
        DataSet dsResult = new DataSet();

        clsSearch_BL clsObj = new clsSearch_BL();
        clsObj.TaskID = (string)Session["TaskID"];
        clsObj.CustName = (string)Session["CustName"];
        clsObj.MarketName = (string)Session["MarketName"];
        clsObj.HeadendName = (string)Session["HeadendName"];
        clsObj.SiteName = (string)Session["SiteName"];
        clsObj.TaskStatus = (string)Session["TaskStatus"];
        clsObj.OrdType = (string)Session["OrdType"];
        clsObj.OrdStatus = (string)Session["OrdStatus"];
        clsObj.ProName = (string)Session["ProName"];
        clsObj.LOC = (string)Session["LOC"];
        clsObj.QuoteID = (string)Session["QuoteID"];
        clsObj.CMNumber = (string)Session["CMNumber"];

        if (Session["SearchRes"] == null)
        {
            dsResult = clsObj.getSearchResults_BL(clsObj);
            Session["SearchRes"] = dsResult;
        }
        else
            dsResult = (DataSet)Session["SearchRes"];

        DataView dataView = dsResult.Tables[0].DefaultView;
        rg200.DataSource = dsResult;
        rg200.DataBind();
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

protected void rg200_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{

    if (Session["TaskID"] != null)
    {
        string strTaskID = (string)Session["TaskID"];
        if (strTaskID != string.Empty)
        {
            clsTaskUpdates_BL objBL = new clsTaskUpdates_BL();

            GridEditableItem editedItem = e.Item as GridEditableItem;
            //Get the primary key value using the DataKeyValue.      
            string OrdID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["orderId"].ToString();
            //Access the textbox from the edit form template and store the values in string variables.

            string ClarifyAccountNbr = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Clarify Account Nbr")).TextBoxControl.Text;

            string SiteID = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Site ID")).TextBoxControl.Text;

            string QuoteID = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Quote ID")).TextBoxControl.Text;

            CheckBox chkEDP = ((GridCheckBoxColumnEditor)editedItem.EditManager.GetColumnEditor("EDP Created?")).CheckBoxControl;

            //string ClarifyAccountNbr = (editedItem["Clarify Account Nbr"].Controls[0] as TextBox).Text;
            //string SiteID = (editedItem["Site ID"].Controls[0] as TextBox).Text;
            //string QuoteID = (editedItem["Quote ID"].Controls[0] as TextBox).Text;
            //CheckBox chkEDP = (editedItem["EDP Created?"].Controls[0] as CheckBox);
            try
            {
                objBL.setTask200_Bl(OrdID, ClarifyAccountNbr, SiteID, QuoteID, chkEDP.Checked);
                Session["SearchRes"] = null;

                BindGrid();

            }
            catch (Exception ex)
            {
                rg200.Controls.Add(new LiteralControl("Unable to update Employee. Reason: " + ex.Message));
                e.Canceled = true;
            }
        }
    }
}
protected void rg200_PageIndexChanged(object source, GridPageChangedEventArgs e)
{
    try
    {
        rg200.CurrentPageIndex = e.NewPageIndex;
        BindGrid();
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

I am using Radgrid with pager. When clicking on the next page number on a pager the data is not displaying(not binding the data). Can anyone help me to fix this. here is my code.

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        if (!IsPostBack)
        {
            Session["SearchRes"] = null;
            if (Session["TaskName"] != null)
                lblTskName.Text = Session["TaskName"].ToString();
            Session["FilColms"] = null;
            Session["SortExp"] = null;
            Session["FilExp"] = null;
            Session["ViewAll"] = null;
            BindGrid();
        }
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

private void BindGrid()
{
    try
    {
        DataSet dsResult = new DataSet();

        clsSearch_BL clsObj = new clsSearch_BL();
        clsObj.TaskID = (string)Session["TaskID"];
        clsObj.CustName = (string)Session["CustName"];
        clsObj.MarketName = (string)Session["MarketName"];
        clsObj.HeadendName = (string)Session["HeadendName"];
        clsObj.SiteName = (string)Session["SiteName"];
        clsObj.TaskStatus = (string)Session["TaskStatus"];
        clsObj.OrdType = (string)Session["OrdType"];
        clsObj.OrdStatus = (string)Session["OrdStatus"];
        clsObj.ProName = (string)Session["ProName"];
        clsObj.LOC = (string)Session["LOC"];
        clsObj.QuoteID = (string)Session["QuoteID"];
        clsObj.CMNumber = (string)Session["CMNumber"];

        if (Session["SearchRes"] == null)
        {
            dsResult = clsObj.getSearchResults_BL(clsObj);
            Session["SearchRes"] = dsResult;
        }
        else
            dsResult = (DataSet)Session["SearchRes"];

        DataView dataView = dsResult.Tables[0].DefaultView;
        rg200.DataSource = dsResult;
        rg200.DataBind();
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

protected void rg200_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{

    if (Session["TaskID"] != null)
    {
        string strTaskID = (string)Session["TaskID"];
        if (strTaskID != string.Empty)
        {
            clsTaskUpdates_BL objBL = new clsTaskUpdates_BL();

            GridEditableItem editedItem = e.Item as GridEditableItem;
            //Get the primary key value using the DataKeyValue.      
            string OrdID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["orderId"].ToString();
            //Access the textbox from the edit form template and store the values in string variables.

            string ClarifyAccountNbr = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Clarify Account Nbr")).TextBoxControl.Text;

            string SiteID = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Site ID")).TextBoxControl.Text;

            string QuoteID = ((GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("Quote ID")).TextBoxControl.Text;

            CheckBox chkEDP = ((GridCheckBoxColumnEditor)editedItem.EditManager.GetColumnEditor("EDP Created?")).CheckBoxControl;

            //string ClarifyAccountNbr = (editedItem["Clarify Account Nbr"].Controls[0] as TextBox).Text;
            //string SiteID = (editedItem["Site ID"].Controls[0] as TextBox).Text;
            //string QuoteID = (editedItem["Quote ID"].Controls[0] as TextBox).Text;
            //CheckBox chkEDP = (editedItem["EDP Created?"].Controls[0] as CheckBox);
            try
            {
                objBL.setTask200_Bl(OrdID, ClarifyAccountNbr, SiteID, QuoteID, chkEDP.Checked);
                Session["SearchRes"] = null;

                BindGrid();

            }
            catch (Exception ex)
            {
                rg200.Controls.Add(new LiteralControl("Unable to update Employee. Reason: " + ex.Message));
                e.Canceled = true;
            }
        }
    }
}
protected void rg200_PageIndexChanged(object source, GridPageChangedEventArgs e)
{
    try
    {
        rg200.CurrentPageIndex = e.NewPageIndex;
        BindGrid();
    }
    catch (Exception ex)
    {
        throw ex;
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骑趴 2024-09-15 17:21:04

您的代码显示您使用了与 DataBind() 调用的绑定。这样您应该手动更改页面索引挂钩PageIndexChanged,将数据源分配给网格并绑定它。或者,使用 NeedDataSource 绑定 来节省一些手动编码。

Your code shows that you use binding with DataBind() calls. In this way you should manually change the page index hooking PageIndexChanged, assign data source to the grid and bind it. Alternatively, use NeedDataSource binding to spare some manual coding.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文