protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { Thread categoryThread = new Thread(new ThreadStart(BindCategory)); Thread newsThread = new Thread(new ThreadStart(BindNews)); categoryThread.Start(); newsThread.Start(); categoryThread.Join(); newsThread.Join(); } catch (Exception ex) { Response.Write(ex); } } }
void BindCategory() { SqlConnection conn = ReturnSqlconn(); SqlCommand comm = new SqlCommand("select * from [dbo].[Channel_List]", conn); conn.Open(); SqlDataReader sdr = comm.ExecuteReader(); GridView1.DataSource = sdr; GridView1.DataBind(); } void BindNews() { SqlConnection conn = ReturnSqlconn(); SqlCommand comm = new SqlCommand("select * from [dbo].[Channel_Type]", conn); conn.Open(); SqlDataReader sdr = comm.ExecuteReader(); GridView2.DataSource = sdr; GridView2.DataBind(); }
public SqlConnection ReturnSqlconn() { string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString; SqlConnection cn = new SqlConnection(connectionString); return cn; }