Esempio n. 1
0
    private void Bindddlbuyer()
    {
        GetByr.AppendDataBoundItems = true;
        SqlConnection conn     = new SqlConnection(DbConnect.x);
        String        strQuery = "select byr_id,byr_nm from Buyer_Tab order by byr_nm ASC ";
        SqlCommand    cmd      = new SqlCommand();

        cmd.CommandType = CommandType.Text;
        cmd.CommandText = strQuery;
        cmd.Connection  = conn;
        try
        {
            conn.Open();
            GetByr.DataSource     = cmd.ExecuteReader();
            GetByr.DataTextField  = "byr_nm";
            GetByr.DataValueField = "byr_id";

            GetByr.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            conn.Close();
            conn.Dispose();
        }
    }
Esempio n. 2
0
 private void BindGetByr()
 {
     using (SqlConnection conn = new SqlConnection(DbConnect.x))
     {
         SqlCommand cmd = new SqlCommand("Select byr_id, byr_nm FROM Buyer_Tab", conn);
         GetByr.AppendDataBoundItems = true;
         conn.Open();
         SqlDataReader rdr = cmd.ExecuteReader();
         GetByr.DataTextField  = "byr_nm";
         GetByr.DataValueField = "byr_id";
         GetByr.DataSource     = rdr;
         GetByr.DataBind();
     }
 }