BINDING DROPDOWNLIST

Ankit Singh

Total Post:341

Points:2389
Posted by  Ankit Singh
 1041  View(s)
Ratings:
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;

  1. Sumit Kesarwani

    Post:378

    Points:2694
    Re: binding dropdownlist

    Hi Ankit,


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

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!