protected void AddPurchase1_Click(object sender, EventArgs e) { if (PurchasePriceTextBox.Text == "" || QuantityTextBox.Text == "" || TotalResultTxtBox1.Text == "") { ErrorLbl.Text = "Fields cannot be empty"; } else { DataTable dt = new DataTable(); dt.Columns.Add("SupplierName"); dt.Columns.Add("MedicineName"); dt.Columns.Add("Price"); dt.Columns.Add("Quantity"); dt.Columns.Add("Amount"); for (int row = 0; row < DetailsGridView.Rows.Count; row++) { DataRow dr = dt.NewRow(); dr[0] = DetailsGridView.Rows[row].Cells[0].Text; dr[1] = DetailsGridView.Rows[row].Cells[1].Text; dr[2] = DetailsGridView.Rows[row].Cells[2].Text; dr[3] = DetailsGridView.Rows[row].Cells[3].Text; dr[4] = DetailsGridView.Rows[row].Cells[4].Text; dt.Rows.Add(dr); } dt.Rows.Add(SupplierDDL.SelectedItem.Value, MedicineNameDDL.SelectedItem.Value, QuantityTextBox.Text, PurchasePriceTextBox.Text, TotalResultTxtBox1.Text); ViewState["dt"] = dt; DetailsGridView.DataSource = ViewState["dt"] as DataTable; DetailsGridView.DataBind(); PurchasePriceTextBox.Text = ""; QuantityTextBox.Text = ""; TotalResultTxtBox1.Text = ""; } }
protected void SearchResultGridView_SelectedIndexChanged(object sender, EventArgs e) { try { GridViewRow gridViewRow = SearchResultGridView.SelectedRow; DataTable dtMovieDetails, dtCastDetails; string id = gridViewRow.Cells[0].Text; dtMovieDetails = BALObj.GetMovieDetails(Convert.ToInt16(id)); dtCastDetails = BALObj.GetCastDetails(Convert.ToInt16(id)); DetailNameLabel.Text = dtMovieDetails.Rows[0][0].ToString(); DetailDescriptionLabel.Text = dtMovieDetails.Rows[0][1].ToString(); DetailReleaseLabel.Text = dtMovieDetails.Rows[0][2].ToString(); DetailGenreLabel.Text = dtMovieDetails.Rows[0][3].ToString(); DetailRatingLabel.Text = dtMovieDetails.Rows[0][4].ToString(); DetailsGridView.DataSource = dtCastDetails; DetailsGridView.DataBind(); } catch (Exception) { ErrorLabel.Visible = true; ErrorLabel.Text = "Somthing went wrong"; } }
protected void DetailsGridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { int index = Convert.ToInt32(e.RowIndex); DataTable dt = ViewState["dt"] as DataTable; dt.Rows[index].Delete(); ViewState["dt"] = dt; DetailsGridView.DataSource = ViewState["dt"] = dt; DetailsGridView.DataBind(); }
private void BindGrid() { DataTable dt = new DataTable(); SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["PharmacyConnectionString"].ConnectionString); conn.Open(); SqlCommand command = new SqlCommand("select a.SupplierName, a.MedicineName,a.Quantity,a.Price,a.Amount from DetailsList b left outer join ProductList a on a.ProductID=b.ProductID where PurchaseID =" + PurchaseID, conn); SqlDataAdapter adapter = new SqlDataAdapter(command); adapter.Fill(dt); ViewState["dt"] = dt; DetailsGridView.DataSource = dt; DetailsGridView.DataBind(); }
protected void displayinfo(object sender, EventArgs e) { String value = names.SelectedItem.Text; String value2 = year.SelectedItem.Text; GoGreen gg = new GoGreen(value, value2); if (value == "---Select---") { // Result.Attributes.Add("style", "visibility: hidden"); } else { DataSet ds = ggDAO.populateGreenTable(gg); DetailsGridView.DataSource = ds.Tables[0]; DetailsGridView.DataBind(); } }
protected void AddButton_Click(object sender, EventArgs e) { // dataTable = (DataTable)ViewState["Details"]; // dataTable.Rows.Add(txtusername.Text,txtRoll.Text,txtGender.Text); // DetailsGridView.DataSource = dataTable; // DetailsGridView.DataBind(); DataTable dataTable = new DataTable(); dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Roll", typeof(int)); dataTable.Columns.Add("Gender", typeof(string)); DataRow dr = null; if (ViewState["Details"] != null) { for (int i = 0; i < 1; i++) { dataTable = (DataTable)ViewState["Details"]; if (dataTable.Rows.Count > 0) { dr = dataTable.NewRow(); dr["Name"] = txtusername.Text; dr["Roll"] = txtRoll.Text; dr["Gender"] = txtGender.Text; dataTable.Rows.Add(dr); DetailsGridView.DataSource = dataTable; DetailsGridView.DataBind(); } } } else { dr = dataTable.NewRow(); dr["Name"] = txtusername.Text; dr["Roll"] = txtRoll.Text; dr["Gender"] = txtGender.Text; dataTable.Rows.Add(dr); DetailsGridView.DataSource = dataTable; DetailsGridView.DataBind(); } ViewState["Details"] = dataTable; }
public void LoadGridview() { try { DataTable dataTable = new DataTable(); if (ViewState["Row"] != null) { dataTable = (DataTable)ViewState["Row"]; DataRow dr = null; if (dataTable.Rows.Count > 0) { dr["Name"] = txtusername.Text; dr["Roll"] = txtRoll.Text; dr["Gender"] = txtGender.Text; dataTable.Rows.Add(dr); ViewState["Row"] = dataTable; DetailsGridView.DataSource = ViewState["Row"]; DetailsGridView.DataBind(); } } else { dataTable.Columns.Add("Name", typeof(string)); dataTable.Columns.Add("Roll", typeof(int)); dataTable.Columns.Add("Gender", typeof(string)); DataRow dr1 = dataTable.NewRow(); dr1 = dataTable.NewRow(); dr1["Name"] = txtusername.Text; dr1["Roll"] = txtRoll.Text; dr1["Gender"] = txtGender.Text; dataTable.Rows.Add(dr1); ViewState["Row"] = dataTable; DetailsGridView.DataSource = ViewState["Row"]; DetailsGridView.DataBind(); } } catch (Exception ex) { } }
/// <summary> /// Gets the details. /// </summary> private void GetDetails() { LotusDataContext db = new LotusDataContext(); var source1 = from b in db.bookings join p in db.pages on b.page_id equals p.page_id where (b.id == int.Parse(ResultsGridView.SelectedDataKey.Value.ToString())) orderby b.id descending select new { ID = b.id, User = b.user_name, Service = p.title, Date = b.submited_date.ToString(), Status = b.status }; var s = from d in db.form_datas join p in db.form_field_definitions on d.form_field_definition_id equals p.form_field_definition_id where (d.form_data_id == int.Parse(ResultsGridView.SelectedDataKey.Value.ToString())) orderby d.form_data_id descending select new { p.form_field_name, p.input_type, d.value1, d.value2, d.value3, d.value4, d.value5, d.value6 }; DataTable table = new DataTable(); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Value", typeof(string)); foreach (var item in s) { if (item.input_type != "header" && item.input_type != "lblNoName" && item.input_type != "label") { DataRow dr = table.NewRow(); dr["Name"] = item.form_field_name; if (item.value1 != null) { dr["Value"] = item.value1.ToString(); } else if (item.value2 != null) { dr["Value"] = item.value2.ToString(); } else if (item.value3 != null) { dr["Value"] = item.value3.ToString(); } else if (item.value4 != null) { dr["Value"] = item.value4.ToString(); } else if (item.value5 != null) { dr["Value"] = item.value5.ToString(); } else if (item.value6 != null) { dr["Value"] = item.value6.Value.ToShortDateString(); } table.Rows.Add(dr); } } DataView dv = new DataView(table); DetailsGridView.DataSource = dv; DetailsGridView.DataBind(); DetailsView.DataSource = source1; DetailsView.DataBind(); if (DetailsView.Rows[2].Cells[1].Text == "Taxi") { ChatButton.Visible = true; //bookingId = ResultsGridView.SelectedDataKey.Value.ToString(); //string query = EncodingDecoding.EncodeMd5(bookingId); //string value = string.Format("window.open('chat.aspx?ChatID={0}',null,'height=400, width=430, left=200, top=150, status= no, resizable= no, scrollbars=no, toolbar=no, location=no, menubar=no ');", query); //ChatButton.Attributes.Add("onclick", value); } else { ChatButton.Visible = false; } DetailsPanel.Visible = true; ResultsGridView.Visible = false; OperatorRadioButtonList.Visible = false; }
/// <summary> /// Handles the SelectedIndexChanged event of the ArchivesGridView control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void ArchivesGridView_SelectedIndexChanged(object sender, EventArgs e) { LotusDataContext db = new LotusDataContext(); var source1 = from b in db.bookings join p in db.pages on b.page_id equals p.page_id where (b.id == int.Parse(ArchivesGridView.SelectedDataKey.Value.ToString())) orderby b.id descending select new { ID = b.id, User = b.user_name, Service = p.title, Date = b.submited_date.ToString(), Status = b.status }; var s = from d in db.form_datas join p in db.form_field_definitions on d.form_field_definition_id equals p.form_field_definition_id where (d.form_data_id == int.Parse(ArchivesGridView.SelectedDataKey.Value.ToString())) orderby d.form_data_id descending select new { p.form_field_name, p.input_type, d.value1, d.value2, d.value3, d.value4, d.value5, d.value6 }; DataTable table = new DataTable(); table.Columns.Add("Name", typeof(string)); table.Columns.Add("Value", typeof(string)); foreach (var item in s) { if (item.input_type != "header" && item.input_type != "lblNoName" && item.input_type != "label") { DataRow dr = table.NewRow(); dr["Name"] = item.form_field_name; if (item.value1 != null) { dr["Value"] = item.value1.ToString(); } else if (item.value2 != null) { dr["Value"] = item.value2.ToString(); } else if (item.value3 != null) { dr["Value"] = item.value3.ToString(); } else if (item.value4 != null) { dr["Value"] = item.value4.ToString(); } else if (item.value5 != null) { dr["Value"] = item.value5.ToString(); } else if (item.value6 != null) { dr["Value"] = item.value6.Value.ToShortDateString(); } table.Rows.Add(dr); } } DataView dv = new DataView(table); DetailsGridView.DataSource = dv; DetailsGridView.DataBind(); DetailsView.DataSource = source1; DetailsView.DataBind(); DetailsPanel.Visible = true; ArchivesPanel.Visible = false; if (DetailsView.Rows[2].Cells[1].Text == "Taxi") { ChatLogButton.Visible = true; } OperatorRadioButtonList.Visible = false; }
protected void ClearButton_Click(object sender, EventArgs e) { DetailsGridView.DataSource = null; DetailsGridView.DataBind(); ViewState["Details"] = null; }