using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.Data.SqlClient; using System.Net.Mail; using System.IO; using System.ComponentModel; using System.Drawing; using System.Web.SessionState; namespace AccountManagement { public partial class Account : System.Web.UI.Page { SqlConnection con; SqlDataAdapter da; SqlDataReader dr; //DataSet ds1; // String Sql; //int Count; DataTable dt; SqlCommand cmd; protected void Page_Load(object sender, EventArgs e) { string s = ConfigurationManager.ConnectionStrings["conn"].ConnectionString; con = new SqlConnection(s); //if (!IsPostBack) //{ // bindgrid(); // bindlst(); //} con.Open(); } //protected void Button1_Click(object sender, EventArgs e) //{ // bindgrid(); // GridView1.Visible = true; //} public void bindgrid() { cmd=new SqlCommand ("select distinct Fname,Lname from Client_registration_tbl",con); //ds1 = new DataSet(); con.Open(); dr = cmd.ExecuteReader(); //da.Fill(ds1); GridView1.DataSource = dr; GridView1.DataBind(); GridView1.Visible = true; con.Close(); } public void bindlst() { da = new SqlDataAdapter("select distinct Fname,Lname from Client_registration_tbl", con); dt = new DataTable(); da.Fill(dt); DropDownList1.DataSource = dt; DropDownList1.DataBind(); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { da = new SqlDataAdapter("select distinct Fname,Lname from Client_registration_tbl" + DropDownList1.SelectedItem.Text + "", con); dt = new DataTable(); da.Fill(dt); GridView1.DataSource = dt; GridView1.DataBind(); bindgrid(); bindlst(); //GridView1.Visible = true; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)