Home > DeveloperSection > Forums > binding dropdownlist
Ankit Singh

Total Post:341

Points:2389
Posted on    September-05-2014 12:09 AM

 ASP.Net ASP.Net 
Ratings:


 1 Reply(s)
 718  View(s)
Rate this:

I have a Class in the App_code folder that contain Method like this:

public static  GetAllCustomers()

{

    string conn = ConfigurationManager.ConnectionStrings["ConnectToDB"].ConnectionString;

    using (SqlConnection connection= new SqlConnection(conn))

    {

        using (SqlCommand cmd = new SqlCommand())

        {

            cmd.CommandText = "select C_ID,L_ID,C_Name from Customer";

            cmd.Connection = connection;

            connection.Open();

        }

    }

    return;



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-05-2014 12:30 AM

Hi Ankit,

You can return a System.Data.DataTable and use column names for datatextfield and datavaluefield.


Don't want to miss updates? Please click the below button!

Follow MindStick