public void buttonCOClicked(object sender, EventArgs args) { string connetionString; SqlConnection cnn; connetionString = WebConfigurationManager.ConnectionStrings["constr"].ConnectionString; cnn = new SqlConnection(connetionString); cnn.Open(); SqlDataAdapter c1 = new SqlDataAdapter("Order_Contributor", cnn); c1.SelectCommand.CommandType = System.Data.CommandType.StoredProcedure; DataTable tab = new DataTable(); c1.Fill(tab); Table3.DataSource = tab; Table3.DataBind(); cnn.Close(); }
private void LoadTableDemo() { DataTable dt = new DataTable(); dt.Columns.Add("Id", typeof(int)); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Age", typeof(string)); for (int i = 0; i < 3; i++) { int id = i + 1; DataRow row = dt.NewRow(); row["Id"] = id; row["Name"] = "Name " + id; row["Age"] = id * 10; dt.Rows.Add(row); } Table1.DataSource = dt; Table1.DataBind(); Table2.DataSource = dt; Table2.DataBind(); Table3.DataSource = dt; Table3.DataBind(); Table4.DataSource = dt; Table4.DataBind(); Table5.DataSource = dt; Table5.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { string connetionString; SqlConnection cnn; connetionString = WebConfigurationManager.ConnectionStrings["constr"].ConnectionString; cnn = new SqlConnection(connetionString); cnn.Open(); int vw_id = Convert.ToInt32(Session["ids"]); String sql = "Select ID,information,contributor_id From New_Request WHERE viewer_id=" + "'" + vw_id + "'" + "AND accept_status IS NULL"; SqlDataAdapter sda = new SqlDataAdapter(sql, cnn); DataTable t3 = new DataTable(); sda.Fill(t3); Table3.DataSource = t3; Table3.DataBind(); cnn.Close(); }