private void oThertext() { SqlConnection cono = new SqlConnection(constr); cono.Open(); try { string str = "select AMS_AssetID,AMS_AssetName,AMS_AssetType,AMS_Company_Location,AMS_Date_of_Purchase,AMS_Remarks from Asset_Master where (AMS_AssetID Like '%' + @AMS_AssetID +'%' or " + "AMS_AssetName Like '%' + @AMS_AssetName + '%' or " + " AMS_AssetType = @AMS_AssetType or " + " AMS_Company_Location Like '%' + @AMS_Company_Location )"; SqlCommand cmd = new SqlCommand(str, cono); cmd.Parameters.Add("@AMS_AssetID", SqlDbType.NVarChar).Value = txtFindVendor.Text; cmd.Parameters.Add("@AMS_AssetName", SqlDbType.NVarChar).Value = txtFindVendor.Text; cmd.Parameters.Add("@AMS_AssetType", SqlDbType.NVarChar).Value = ReportAssetType.SelectedValue.Trim(); cmd.Parameters.Add("@AMS_Company_Location", SqlDbType.NVarChar).Value = txtFindVendor.Text.Trim(); cmd.ExecuteNonQuery(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataSet ds = new DataSet(); da.Fill(ds, "@AMS_AssetID"); da.Fill(ds, "@AMS_AssetName"); da.Fill(ds, "@AMS_AssetType"); da.Fill(ds, "@AMS_Company_Location"); Othersgridview.DataSource = ds; Othersgridview.DataBind(); } catch (Exception) { ClientScript.RegisterStartupScript(GetType(), "alert", "alert('There is no approved Data.');", true); } finally { cono.Close(); } }
protected void txtFindVendor_TextChanged(object sender, EventArgs e) { if (Page.IsPostBack == true) { searchdiv.Visible = true; if (txtFindVendor.Text != string.Empty.ToString() && ReportAssetType.SelectedIndex == 1) { Othersgridview.DataSourceID = "SWSqlDataSource"; Othersgridview.DataBind(); if (Othersgridview.Rows.Count == 0) { txtFindVendor.Text = string.Empty; Othersgridview.Visible = true; Othersgridview.EmptyDataText = "No Records Found / Invalid Search"; Otherexporttoexcell.Visible = false; } else { Otherexporttoexcell.Visible = true; } } else if (txtFindVendor.Text != string.Empty.ToString() && ReportAssetType.SelectedIndex == 2) { Othersgridview.DataSourceID = "HWSqlDataSource"; Othersgridview.DataBind(); if (Othersgridview.Rows.Count == 0) { txtFindVendor.Text = string.Empty; Othersgridview.Visible = true; Othersgridview.EmptyDataText = "No Records Found / Invalid Search"; Otherexporttoexcell.Visible = false; } else { Otherexporttoexcell.Visible = true; } } else { Response.Redirect("~/Admin/Asset-Reports.aspx"); } } }