private void RefreshData() { var data = imsdb.Customers.OrderByDescending(d => d.Id).ToList(); GridViewCustomer.DataSource = data; GridViewCustomer.DataBind(); }
protected void BindGridList() { GridViewCustomer.DataSource = ELCustomerList; GridViewCustomer.DataBind(); //GridViewCustomer.HeaderRow.TableSection = TableRowSection.TableFooter; GridViewCustomer.HeaderRow.TableSection = TableRowSection.TableHeader; }
private void BindGridViewCustomer() { try { if (conn.State == ConnectionState.Closed) { conn.Open(); } SqlCommand cmd = new SqlCommand("USP_SelectInContactInformation", conn); cmd.CommandType = CommandType.StoredProcedure; SqlDataAdapter adp = new SqlDataAdapter(cmd); DataSet ds = new DataSet(); adp.Fill(ds); GridViewCustomer.DataSource = ds; GridViewCustomer.DataBind(); lbltotalcount.Text = GridViewCustomer.Rows.Count.ToString(); } catch (SqlException ex) { ShowMessage(ex.Message); } finally { if (conn.State == ConnectionState.Open) { conn.Close(); } } }
public void loadDataUser() { //user = new User(); //GridViewCustomer.DataSource = user.selectUser(); users = new UserDic(); users.selectUsers(); GridViewCustomer.DataSource = users.Values; GridViewCustomer.DataBind(); }
protected void btnSearch_Click(object sender, EventArgs e) { if (DropDownList1.SelectedIndex == 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Error", "alert('Please select a field')", true); } else { GridViewCustomer.DataSource = null; GridViewCustomer.DataBind(); string Field = DropDownList1.SelectedValue.ToString(); string SearchVal = txfSearch.Text.ToString(); string AllFields = "HomeAssistPanicSOS,MemberStatus,PolicyType,MemberNo,Policy_Inception_date,CancellationDate,Title,Name,Surname,IDNumber,PassportNumber,TelHome,TelWork,TelOther,MainEmailAddress,AltEmailAddress,ResidentialAddressComplexNo,ResidentialAddressComplexName,ResidentialAddressStreetNo,ResidentialAddressStreetName,ResidentialAddressSuburb,ResidentialAddressPOcode,ResidentialAddressProvince"; string adp = $"SELECT { AllFields} FROM Client WHERE[{ Field}] LIKE '%{SearchVal}%'"; if (Field == "TelHome") { adp = $"SELECT {AllFields} FROM Client WHERE TelHome LIKE '%{SearchVal}%' OR TelWork LIKE '%{SearchVal}%' OR TelOther LIKE '%{SearchVal}%'"; } if (Field == "Name") { adp = $"SELECT {AllFields} FROM Client WHERE Name LIKE '%{SearchVal}%' OR Surname LIKE '%{SearchVal}%'"; } var output = database.FetchQuery(adp); try { GridViewCustomer.DataSource = output; GridViewCustomer.DataBind(); foreach (GridViewRow dr in GridViewCustomer.Rows) { try { DateTime dts1 = Convert.ToDateTime(dr.Cells[4].Text); dr.Cells[4].Text = dts1.ToString("dd MMM yyyy"); } catch (Exception) { } } if (output.Count > 0) { try { SendLogData(output.Count + "", Field, SearchVal, DateTime.Now.ToString("dd MMM yyyy hh:mm:ss")); } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Error", "alert('Unable To send Data " + ex + "')", true); } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(UpdatePanel1, UpdatePanel1.GetType(), "Error", "alert('Could not load due to " + ex + "')", true); } } }
protected void Page_Load(object sender, EventArgs e) { try { if (Session["typeid"].ToString() != "2") { Response.Redirect("~/Login/Login.aspx"); } } catch (Exception) { Response.Redirect("~/Login/Login.aspx"); } if (!IsPostBack) { var data = imsdb.Customers.OrderByDescending(d => d.Id).ToList(); GridViewCustomer.DataSource = data; GridViewCustomer.DataBind(); } }
protected void BindGridViewCustomer() { sqlConnectionOBJ.ConnectionString = "Data Source=DESKTOP-P0QRTM4;Initial Catalog=DatabaseSystems8490;Integrated Security=True"; try { sqlConnectionOBJ.Open(); sqlCommandOBJ.CommandText = "SELECT * FROM Customer"; sqlCommandOBJ.Connection = sqlConnectionOBJ; sqlDataAdapterOBJ.SelectCommand = sqlCommandOBJ; dataSetOBJ = new DataSet(); sqlDataAdapterOBJ.Fill(dataSetOBJ, "Customer"); //we are expecting a DataSet/ResultSet back if (dataSetOBJ.Tables[0].Rows.Count > 0) //run if there's more than one row in the dataset { GridViewCustomer.DataSource = dataSetOBJ; GridViewCustomer.DataBind(); } else { } } catch (SqlException ex) { lblMessage.Visible = true; lblMessage.Text = "SqlException*** ERROR*** \n " + ex.Message; throw; } finally { sqlConnectionOBJ.Close(); sqlConnectionOBJ.Dispose(); } }
private void BindGrid() { using (SqlConnection constr = new SqlConnection()); { using (SqlCommand cmd = new SqlCommand("dbo.StoredProCustomer")) { cmd.Parameters.AddWithValue("@Action", "SELECT"); using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.CommandType = CommandType.StoredProcedure; cmd.Connection = con; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); GridViewCustomer.DataSource = dt; GridViewCustomer.DataBind(); } } } } }