代码之家  ›  专栏  ›  技术社区  ›  Tronics

PageIndexChanged不工作

  •  0
  • Tronics  · 技术社区  · 15 年前

    我正在使用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;
        }
    }
    
    1 回复  |  直到 12 年前
        1
  •  0
  •   Dick Lampard    15 年前

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

    推荐文章