public void BindProjects() { string sortbycoloumn = (ViewState["PROJECTSORTBYCOLOUMN"] == null) ? null : (ViewState["PROJECTSORTBYCOLOUMN"].ToString()); int? sortdirection = null; if (ViewState["PROJECTSORTDIRECTION"] != null) { sortdirection = Int32.Parse(ViewState["PROJECTSORTDIRECTION"].ToString()); } DataTable dt = BLL_Infra_ShipSettings.Get_Nav_Project_Search(txtSearchProject.Text, sortbycoloumn, sortdirection); if (dt.Rows.Count > 0) { gvProject.DataSource = dt; gvProject.DataBind(); if (ViewState["ProjectID"] == null) { ViewState["ProjectID"] = dt.Rows[0]["Project_ID"].ToString(); gvProject.SelectedIndex = 0; } BindProjectList(Convert.ToInt32(ViewState["ProjectID"].ToString())); SetProjectRowSelection(); } else { gvProject.DataSource = dt; gvProject.DataBind(); ViewState["ProjectID"] = null; } UpdProjectGrid.Update(); }