Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Drawing;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.HtmlControls;
- using System.Web.Services;
- using TSSC_ESC_CCD;
- using System.Data;
- using MySql.Data;
- using MySql.Data.MySqlClient;
- public partial class backCodeExper : System.Web.UI.Page
- {
- protected void saveRecord(string recordID, string buttonId, string dropdownId)
- {
- PlaceHolder db = Page.FindControl("TestingCS") as PlaceHolder;
- HtmlTable tbl = db.FindControl("TestTable") as HtmlTable;
- HtmlTableRow tr = tbl.FindControl("TheRow") as HtmlTableRow;
- HtmlTableCell tc = tr.FindControl("TheCell") as HtmlTableCell;
- DropDownList ddl = tc.FindControl(dropdownId) as DropDownList;
- var status = ddl.SelectedValue.ToString();
- HttpContext context = HttpContext.Current;
- MySqlConnection conn = new MySqlConnection();
- conn.ConnectionString = "Server=localhost; Database********; User=********; Password=********; Port=3306";
- conn.Open();
- MySqlCommand cmd = new MySqlCommand();
- cmd.Connection = conn;
- cmd.CommandType = CommandType.StoredProcedure;
- cmd.CommandText = "updatetesttable";
- cmd.Parameters.AddWithValue("@param", status);
- cmd.ExecuteNonQuery();
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- HtmlTable myTable = new HtmlTable();
- myTable.ID = "TestTable";
- myTable.BorderColor = "teal";
- myTable.BgColor = "black";
- TestingCS.Controls.Add(myTable);
- HtmlTableRow newRow;
- HtmlTableCell cell;
- DropDownList DropList;
- LinkButton saveButton;
- newRow = new HtmlTableRow();
- newRow.ID = "TheRow";
- cell = new HtmlTableCell();
- cell.ID = "TheCell1";
- DropList = new DropDownList();
- DropList.ID = "StatusDD";
- DropList.Items.Add(new ListItem("", "0"));
- DropList.Items.Add(new ListItem("A", "1"));
- DropList.Items.Add(new ListItem("B", "2"));
- DropList.Items.Add(new ListItem("C", "3"));
- cell.Controls.Add(DropList);
- newRow.Cells.Add(cell);
- cell = new HtmlTableCell();
- cell.ID = "TheCell2";
- cell.BgColor = "black";
- saveButton = new LinkButton();
- saveButton.ID = "saveButton";
- saveButton.CommandName = "saveRecord";
- saveButton.CommandArgument = "'1A',this.id,'StatusDD'";
- saveButton.BackColor=Color.Green;
- saveButton.ForeColor=Color.Cyan;
- saveButton.BorderColor=Color.Maroon;
- saveButton.Text = "Save";
- saveButton.Visible = true;
- cell.Controls.Add(saveButton);
- newRow.Cells.Add(cell);
- myTable.Rows.Add(newRow);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement