BOUND CONTROL

 Bound Control :-

The bound control directly communicate to the database column .

Type of bound control.

1. Dropdown list

2. Check box list

3. Radio button list

 

Bound control property.

1. Data source (DR-datareader)

2. Datatext field (column name )

3. Databind (it is a function)

 

 

 

Ø How to add select option inside the dropdown list.

Ex:- // open connection

 

        string path = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\college.mdf;Integrated Security=True";

        con = new SqlConnection(path);

        con.Open();

 

        //apply command

 

        string ct = "select city from CONNECTDB";

        com = new SqlCommand(ct,con);

        dr = com.ExecuteReader();

 

 

        // bound control

 

        DropDownList1.DataSource = dr;

        DropDownList1.DataTextField = "city";

        DropDownList1.DataBind();

 

        // insert select option

 

        DropDownList1.Items.Insert(0, "Select your city");

 

 

 

        dr.Close();

 

Scaler function / SQL function :-(sum,avg,min,max,count…etc)

 // open connection

 

        string path = @"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\college.mdf;Integrated Security=True";

        con = new SqlConnection(path);

        con.Open();

 

        // apply command

 

        String cunt = "select count(Roll) from CONNECTDB";

        com = new SqlCommand(cunt, con);

        Label1.Text = com.ExecuteScalar().ToString(); 

Comments

Popular posts from this blog

ViewState for state management

Store procedure Data Base handling (procedure_insert).

Database joining