Click here to Skip to main content
15,892,737 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The below piece of code is for search gridview via textbox value.the same code works fine in other form. but doesnt work in current form. please help.
P.S:- My sp works fine. i checked it
Thnx.. :)

What I have tried:

C#
protected void btnsearch_Click(object sender, System.EventArgs e)
        {
            lblWarningMessage.Text = "";
            try
            {
                if (!string.IsNullOrEmpty(txtSearch.Text))
                {
                    GVEquipmentAttribute.Visible = true;
                    DataSet dsSite = new DataSet();
                    ArrayList arrparam1 = new ArrayList();
                    arrparam1.Add(txtSearch.Text.Trim());
                    dsSite = objDB.ExecProc_getDataSet("D_SP_GET_EquipmentAttribute_GRID_Search", arrparam1);
                    DataTable dt = new DataTable();
                    if (dsSite.Tables[0].Rows.Count > 0)
                    {
                        //btnDelete.Visible = True
                    }
                    else
                    {
                        //btnDelete.Visible = False
                    }
                    dt = dsSite.Tables[0];

                    GVEquipmentAttribute.DataSource = dt;
                    GVEquipmentAttribute.DataBind();
                }
                else
                {
                    BindGrid();
                }
Posted
Updated 22-Mar-16 18:45pm
Comments
VR Karthikeyan 23-Mar-16 0:31am    
Just debug your code to check whether objDB.ExecProc_getDataSet function returns a dataset or not.

1 solution

Modify it as

C#
DataTable dt = new DataTable();
          dsSite = objDB.ExecProc_getDataSet("D_SP_GET_EquipmentAttribute_GRID_Search", arrparam1);
          if (dsSite != null && dsSite.Tables.Count > 0)
          {
              dt = dsSite.Tables[0];

              if (dt.Rows.Count > 0)
              {
                  //btnDelete.Visible = True
              }
              else
              {
                  //btnDelete.Visible = False
              }
          }


          GVEquipmentAttribute.DataSource = dt;
          GVEquipmentAttribute.DataBind();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900