protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { BindFiles(); } } protected void Button1_Click(object sender, EventArgs e) { /* if (!IsPostBack) { BindFiles(); }*/ } /// <summary> /// Binds the files. /// </summary> private void BindFiles() { DataTable table = new DataTable(); SqlConnection _conn1 = new SqlConnection("Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Northwind;Data Source=KACHU-PC\\SQLEXPRESS"); { string sql = "SELECT imageid, bid, pid FROM myimages Order By bid"; using (SqlCommand cmd = new SqlCommand(sql, _conn1)) { using (SqlDataAdapter ad = new SqlDataAdapter(cmd)) { ad.Fill(table); } } } GridView1.DataSource = table; GridView1.DataBind(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)