绑定方法没有调用我如何纠正.. [英] Bind method doest called how can i correct ..

查看:117
本文介绍了绑定方法没有调用我如何纠正..的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好..

谁能帮我解决我的问题,但是页面上没有任何错误,但是当我运行该页面时,它无法在Grid中加载数据,我认为我在代码中写错了,就是发送代码


Hello Everyone..

can anybody help me about my problem there is no any error in page but when i run that page it cann''t able to load data in Grid, and i think i write something wrong in code here is send the code


protected void Page_Load(object sender, EventArgs e)
  {
       try
      {
          if (!string.IsNullOrEmpty(Request.ServerVariables["QUERY_STRING"]))
          {
              //Page.Form.Action = Request.ServerVariables("SCRIPT_NAME")
          }
          else
          {
              //Page.Form.Action = Request.ServerVariables("SCRIPT_NAME") & "?" & Request.ServerVariables("QUERY_STRING")
          }
          Page.Title = "Administrators" + ConfigurationManager.AppSettings["AdminTitle"];
          dgAdmin.PageSize = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["AdminPagging"]);
          if (Page.IsPostBack == false)
          {
              if (Request["email"] != "" || Request["email"] != null)
              {
                  txtEmail.Text = Request["email"];
              }
              if (Request["Flag"] == "add")
              {
                  trmsg.Visible = true;
                  lblmsgs.Text = "Admin Details are added successfully";
              }
              else if (Request["Flag"] == "edit")
              {
                  trmsg.Visible = true;
                  lblmsgs.Text = "Admin Details are updated successfully";
              }
              else if (Request["Flag"] == "delete")
              {
                  trmsg.Visible = true;
                  lblmsgs.Text = "Admin Details are deleted successfully";
              }
              BindAdmin();
              LoadDropDownList();
          }         
          txtEmail.Attributes.Add("onkeypress", "javascript:return checkKey('" + imgbtnSearch.ClientID + "',event);");
          imgbtnDelete.Attributes.Add("onclick", "javascript:return check();");
      }
      catch (Exception ex)
      {
          lblmsgs.Text = ex.Message;
          trmsg.Visible = true;
      }
  }







public void BindAdmin()
   {
       DataSet dsSelectAdmin = new DataSet();
       objAdmin.emailid = txtEmail.Text.Trim();
       try
       {
           if (Session["AdminType"].ToString() == "subadmin")
           {
               imgbtnDelete.Visible = false;
               imgbtnAdd.Visible = false;
               objAdmin.Id = (int)Session["AdminId"];
               dsSelectAdmin = objAdmin.SelectSingleItem();
           }
           else
           {
               dsSelectAdmin = (DataSet)objAdmin.SearchItem();
           }
           dgAdmin.DataSource = dsSelectAdmin;
           dgAdmin.DataBind();
           if (dsSelectAdmin.Tables[0].Rows.Count > 0)
           {
               trError.Visible = false;
               tradddelete.Visible = true;
               if (dgAdmin.PageCount < 2)
               {
                   dgAdmin.CurrentPageIndex = 0;
               }
               firstprev();
               dsSelectAdmin.Dispose();
               dsSelectAdmin.Clear();
           }
           else
           {
               FirstButton.Visible = false;
               PrevButton.Visible = false;
               NextButton.Visible = false;
               LastButton.Visible = false;
               lblFirstLine.Visible = false;
               lblLastLine.Visible = false;
               lblLine.Visible = false;
               trError.Visible = true;
               lblerror.Text = " Record not found";
           }
       }
       catch (Exception ex)
       {
           lblmsgs.Text = ex.Message;
           trmsg.Visible = true;
       }
   }

推荐答案

narendrarathod写道:
narendrarathod wrote:

if(dgAdmin.PageCount < 2){dgAdmin.CurrentPageIndex = 0; } firstprev(); dsSelectAdmin.Dispose(); dsSelectAdmin.Clear();

if (dgAdmin.PageCount < 2) { dgAdmin.CurrentPageIndex = 0; } firstprev(); dsSelectAdmin.Dispose(); dsSelectAdmin.Clear();



为什么要执行所有这些操作,然后评论并尝试.每次加载数据集都会自动将其设置为第1页.

如果存在问题,请逐行调试它,并查看ig值是否已返回并已绑定.此外,将datagrid Itemdatabound放置在页面中以检查Databind事件.



Why are you doing all these, comment and try. Every load of dataset will automatically set it to page 1.

If issue exists, Debug it line by line and see ig values are returned back and binded or not. Further, Place datagrid Itemdatabound in your page to check the Databind event.


这篇关于绑定方法没有调用我如何纠正..的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆